104_二叉树的最大深度
4/17/26Less than 1 minute
104_二叉树的最大深度
简单class Solution {
public int maxDepth(TreeNode root) {
if(root != null){
return 1 + Math.max(maxDepth(root.left),maxDepth(root.right));
}
return 0;
}
}返回1加上左右子树的最大深度,递归运算得出结果