Simple C solution 0ms


  • 0
    struct TreeNode* invertTree(struct TreeNode* root) {
        if(root==NULL) return NULL;
        struct TreeNode *tmp;
        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.