0ms 5 line C++ solution


  • 6
    F
    TreeNode* invertTree(TreeNode* root) {
            if (!root) return root;
            TreeNode* tmp =invertTree(root->left);
            root->left = invertTree(root->right);
            root->right = tmp;
            return root;
        }

Log in to reply
 

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