A solution in C


  • 6
    M
    struct TreeNode* invertTree(struct TreeNode* root) {
        if(root==NULL)
            return NULL;
        struct TreeNode *tmp = root->left;
        root->left = invertTree(root->right);
        root->right = invertTree(tmp);
        return root;
    }

Log in to reply
 

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