题目来源:
https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
题目描述:
由于该题不难,直接上代码
代码如下:
class Solution {
int result = 0;
public int maxDepth(TreeNode root) {
if (root == null) {
return 0;
}
result = Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
return result;
}
}