1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/二叉树的锯齿形层序遍历 [binary-tree-zigzag-level-order-traversal].html

34 lines
931 B
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<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],[20,9],[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>-100 &lt;= Node.val &lt;= 100</code></li>
</ul>