mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
33 lines
660 B
HTML
33 lines
660 B
HTML
<p>从上到下按层打印二叉树,同一层的节点按从左到右的顺序打印,每一层打印到一行。</p>
|
|
|
|
<p> </p>
|
|
|
|
<p>例如:<br>
|
|
给定二叉树: <code>[3,9,20,null,null,15,7]</code>,</p>
|
|
|
|
<pre> 3
|
|
/ \
|
|
9 20
|
|
/ \
|
|
15 7
|
|
</pre>
|
|
|
|
<p>返回其层次遍历结果:</p>
|
|
|
|
<pre>[
|
|
[3],
|
|
[9,20],
|
|
[15,7]
|
|
]
|
|
</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
<ol>
|
|
<li><code>节点总数 <= 1000</code></li>
|
|
</ol>
|
|
|
|
<p>注意:本题与主站 102 题相同:<a href="https://leetcode-cn.com/problems/binary-tree-level-order-traversal/">https://leetcode-cn.com/problems/binary-tree-level-order-traversal/</a></p>
|