226. Invert Binary Tree easy题
二差树历遍而已
难得我会
但我runtime跟memory超烂
是要改迭代比较好吗
class Solution {
public:
TreeNode* invertTree(TreeNode* root) {
if(root == NULL) return root;
invertTree(root->left);
invertTree(root->right);
swap(root->left, root->right);
return root;
}
};