class Solution {
int maxDepth=0;
int i=1;
public int maxDepth(TreeNode root) {
if(root==null){
return 0;
}
int nleft = maxDepth(root.left);
int nright = maxDepth(root.right);
return nleft > nright ? nleft + 1 : nright + 1;
}
}
leetcode:9.二叉树最大深度 简单
最新推荐文章于 2024-05-25 10:57:37 发布