class Solution {
public int maxDepth(TreeNode root) {
int leftCon = 0;
int rightCon = 0;
if(root == null){
return 0;
}
else {
leftCon = maxDepth(root.left)+1;
rightCon = maxDepth(root.right)+1;
if(leftCon >= rightCon){
return leftCon;
}
else {
return rightCon;
}
}
}
}
LeetCode104--二叉树最大深度
最新推荐文章于 2022-10-27 18:38:05 发布