class Solution {
public int maxDepth(TreeNode root) {
if(root == null) return 0;
int left_h = maxDepth(root.left);
int right_h = maxDepth(root.right);
return Math.max(left_h,right_h) + 1;
}
}
104. 二叉树的最大深度
最新推荐文章于 2024-03-30 12:54:53 发布