C++ Code (recursive version)


  • 0
    int maxDepth(TreeNode* root) {
            if (root == NULL) return 0;
    	int right = maxDepth(root->right);
    	int left = maxDepth(root->left);
    	if (right > left)return ++right;
    	return ++left;
     }
    

Log in to reply
 

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