104. 二叉树的最大深度
作者:互联网
class Solution {
public int maxDepth(TreeNode root) {
if (root == null){
return 0;
}
int leftDepth = maxDepth(root.left);
int rightDepth = maxDepth(root.right);
return Math.max(leftDepth, rightDepth) + 1;
}
}
https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
标签:return,int,leftDepth,rightDepth,maxDepth,深度,root,104,二叉树 来源: https://www.cnblogs.com/taoyuann/p/15471370.html