C++,0ms,is simple and easy to understand ,


  • 8
    D
    TreeNode* invertTree(TreeNode* root) {
        TreeNode* temp;
        if(root==NULL) return root;
        temp=root->left;
        root->left=invertTree(root->right);
        root->right=invertTree(temp);
        return root;
    }

Log in to reply
 

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