mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
33 lines
780 B
HTML
33 lines
780 B
HTML
<p>给定一个二叉树 <code>root</code> ,返回其最大深度。</p>
|
||
|
||
<p>二叉树的 <strong>最大深度</strong> 是指从根节点到最远叶子节点的最长路径上的节点数。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg" style="width: 400px; height: 277px;" /></p>
|
||
|
||
<p> </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> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li>树中节点的数量在 <code>[0, 10<sup>4</sup>]</code> 区间内。</li>
|
||
<li><code>-100 <= Node.val <= 100</code></li>
|
||
</ul>
|