递归调用
代码:
class Solution {
public:
TreeNode* invertTree(TreeNode* root) {
if(root==NULL) return NULL;
invertTree(root->left);
invertTree(root->right);
TreeNode* p=root->left;
root->left=root->right;
root->right=p;
return root;
}
};