Accepted C post-order recursive solution,too simple to explain


  • 2
    R

    it is a simple problem.

    struct TreeNode* invertTree(struct TreeNode* root) {
    	if(NULL==root) return root;
        
    	struct TreeNode *i_l=invertTree(root->left);
    	struct TreeNode *i_r=invertTree(root->right);
    	root->left=i_r;
    	root->right=i_l;
    
    	return root;
    }

Log in to reply
 

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