4 line simple,c++ solution 0ms


  • 0
    J
    class Solution {
    

    public:

    TreeNode* invertTree(TreeNode* root) {
        if(root) {
        swap(root->right, root->left);
        invertTree(root->right);
        invertTree(root->left);
        }
        return root;
    }
    

    };


Log in to reply
 

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