1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-30 12:10:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/二叉树的最大深度 [maximum-depth-of-binary-tree].html

33 lines
780 B
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给定一个二叉树 <code>root</code> ,返回其最大深度。</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p>二叉树的 <strong>最大深度</strong> 是指从根节点到最远叶子节点的最长路径上的节点数。</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p><strong>示例 1</strong></p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p><img alt="" src="https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg" style="width: 400px; height: 277px;" /></p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
<pre>
<b>输入:</b>root = [3,9,20,null,null,15,7]
<b>输出:</b>3
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>root = [1,null,2]
<b>输出:</b>2
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>树中节点的数量在&nbsp;<code>[0, 10<sup>4</sup>]</code>&nbsp;区间内。</li>
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
</ul>