我终于也可以,超简洁代码AC了!!!
https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
1 int maxDepth(TreeNode* root) { 2 if(root==NULL) 3 return 0; 4 return max(maxDepth(root->left)+1,maxDepth(root->right)+1); 5 }
我终于也可以,超简洁代码AC了!!!
https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
1 int maxDepth(TreeNode* root) { 2 if(root==NULL) 3 return 0; 4 return max(maxDepth(root->left)+1,maxDepth(root->right)+1); 5 }