Share C++ solution.


  • 0
    A
    class Solution {
    public:
        TreeNode* invertTree(TreeNode* root) {
            if(root)
            {
                swap(root->left, root->right);
                invertTree(root->left);
                invertTree(root->right);
            }
            return root;
        }
    };

Log in to reply
 

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