[C++] could it be any simplier?


  • 1
    S
    class Solution {
    public:
        TreeNode* invertTree(TreeNode* root) {
            if(root==NULL) return NULL;
            TreeNode* tmp=invertTree(root->right);
            root->right=invertTree(root->left);
            root->left=tmp;
            return root;
            
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.