mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
24 lines
682 B
HTML
24 lines
682 B
HTML
|
<p>输入一棵二叉树的根节点,求该树的深度。从根节点到叶节点依次经过的节点(含根、叶节点)形成树的一条路径,最长路径的长度为树的深度。</p>
|
|||
|
|
|||
|
<p>例如:</p>
|
|||
|
|
|||
|
<p>给定二叉树 <code>[3,9,20,null,null,15,7]</code>,</p>
|
|||
|
|
|||
|
<pre> 3
|
|||
|
/ \
|
|||
|
9 20
|
|||
|
/ \
|
|||
|
15 7</pre>
|
|||
|
|
|||
|
<p>返回它的最大深度 3 。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ol>
|
|||
|
<li><code>节点总数 <= 10000</code></li>
|
|||
|
</ol>
|
|||
|
|
|||
|
<p>注意:本题与主站 104 题相同:<a href="https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/">https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/</a></p>
|