|
1 | 1 | [#0104-maximum-depth-of-binary-tree] |
2 | | -= 104. Maximum Depth of Binary Tree |
| 2 | += 104. 二叉树的最大深度 |
3 | 3 |
|
4 | | -{leetcode}/problems/maximum-depth-of-binary-tree/[LeetCode - Maximum Depth of Binary Tree^] |
| 4 | +https://leetcode.cn/problems/maximum-depth-of-binary-tree/[LeetCode - 104. 二叉树的最大深度^] |
5 | 5 |
|
6 | | -Given a binary tree, find its maximum depth. |
| 6 | +给定一个二叉树 `root` ,返回其最大深度。 |
7 | 7 |
|
8 | | -The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. |
| 8 | +二叉树的 *最大深度* 是指从根节点到最远叶子节点的最长路径上的节点数。 |
9 | 9 |
|
10 | | -*Note:* A leaf is a node with no children. |
| 10 | +*示例 1:* |
11 | 11 |
|
12 | | -*Example:* |
| 12 | +image::images/0104-01.jpg[{image_attr}] |
13 | 13 |
|
14 | | -Given binary tree `[3,9,20,null,null,15,7]`, |
| 14 | +.... |
| 15 | +输入:root = [3,9,20,null,null,15,7] |
| 16 | +输出:3 |
| 17 | +.... |
15 | 18 |
|
16 | | -[subs="verbatim,quotes,macros"] |
17 | | ----- |
18 | | - 3 |
19 | | - / \ |
20 | | - 9 20 |
21 | | - / \ |
22 | | - 15 7 |
23 | | ----- |
| 19 | +*示例 2:* |
| 20 | + |
| 21 | +.... |
| 22 | +输入:root = [1,null,2] |
| 23 | +输出:2 |
| 24 | +.... |
| 25 | + |
| 26 | +*提示:* |
| 27 | + |
| 28 | +* 树中节点的数量在 `[0, 10^4^]` 区间内。 |
| 29 | +* `+-100 <= Node.val <= 100+` |
24 | 30 |
|
25 | | -return its depth = 3. |
26 | 31 |
|
27 | 32 | == 思路分析 |
28 | 33 |
|
@@ -59,11 +64,21 @@ include::{sourcedir}/_0104_MaximumDepthOfBinaryTree_2.java[tag=answer] |
59 | 64 | include::{sourcedir}/_0104_MaximumDepthOfBinaryTree_3.java[tag=answer] |
60 | 65 | ---- |
61 | 66 | -- |
| 67 | +
|
| 68 | +四刷:: |
| 69 | ++ |
| 70 | +-- |
| 71 | +[{java_src_attr}] |
| 72 | +---- |
| 73 | +include::{sourcedir}/_0104_MaximumDepthOfBinaryTree_4.java[tag=answer] |
| 74 | +---- |
| 75 | +-- |
62 | 76 | ==== |
63 | 77 |
|
64 | 78 | 思考题:尝试使用迭代方式来解决一下。 |
65 | 79 |
|
66 | 80 | == 参考资料 |
67 | 81 |
|
68 | | -. https://leetcode.cn/problems/maximum-depth-of-binary-tree/solutions/349250/er-cha-shu-de-zui-da-shen-du-by-leetcode-solution/[104. 二叉树的最大深度 - 官方题解^] |
| 82 | +. https://leetcode.cn/problems/maximum-depth-of-binary-tree/solutions/2010612/kan-wan-zhe-ge-shi-pin-rang-ni-dui-di-gu-44uz/[104. 二叉树的最大深度 - 让你对递归的理解更上一层楼!^] |
69 | 83 | . https://leetcode.cn/problems/maximum-depth-of-binary-tree/solutions/2361697/104-er-cha-shu-de-zui-da-shen-du-hou-xu-txzrx/[104. 二叉树的最大深度 -后序或层序遍历,清晰图解^] |
| 84 | +. https://leetcode.cn/problems/maximum-depth-of-binary-tree/solutions/349250/er-cha-shu-de-zui-da-shen-du-by-leetcode-solution/[104. 二叉树的最大深度 - 官方题解^] |
0 commit comments