Easy C++ solution


  • 0
    L
        TreeNode* invertTree(TreeNode* root) {
            if (not root) return NULL;
            invertTree(root->left);
            invertTree(root->right);
            TreeNode *r = root->right, *l = root->left;
            root->right = l;
            root->left = r;
            return root;
        }
    

Log in to reply
 

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