LeetCode 104. 二叉树的最大深度

104. 二叉树的最大深度

解题思路

参考代码

1
2
3
4
5
6
7
8
9
10
11
class Solution {
public int maxDepth(TreeNode root) {
if(root == null) {
return 0;
}

int maxL = maxDepth(root.left);
int maxR = maxDepth(root.right);
return Math.max(maxL, maxR) + 1;
}
}

LeetCode 104. 二叉树的最大深度
https://sowink.cn/2026/02/08/LeetCode-104-二叉树的最大深度/
作者
Xurx
发布于
2026年2月8日
许可协议