1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/二叉树的层序遍历 [binary-tree-level-order-traversal].html
2022-03-29 12:43:11 +08:00

34 lines
868 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你二叉树的根节点 <code>root</code> ,返回其节点值的 <strong>层序遍历</strong> 。 (即逐层地,从左到右访问所有节点)。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg" style="width: 277px; height: 302px;" />
<pre>
<strong>输入:</strong>root = [3,9,20,null,null,15,7]
<strong>输出:</strong>[[3],[9,20],[15,7]]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>root = [1]
<strong>输出:</strong>[[1]]
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>root = []
<strong>输出:</strong>[]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>树中节点数目在范围 <code>[0, 2000]</code></li>
<li><code>-1000 &lt;= Node.val &lt;= 1000</code></li>
</ul>