1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/二叉树寻路 [path-in-zigzag-labelled-binary-tree].html
2022-03-29 12:43:11 +08:00

32 lines
1.1 KiB
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>在一棵无限的二叉树上,每个节点都有两个子节点,树中的节点 <strong>逐行</strong> 依次按&nbsp;&ldquo;&rdquo; 字形进行标记。</p>
<p>如下图所示,在奇数行(即,第一行、第三行、第五行&hellip;&hellip;)中,按从左到右的顺序进行标记;</p>
<p>而偶数行(即,第二行、第四行、第六行&hellip;&hellip;)中,按从右到左的顺序进行标记。</p>
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/06/28/tree.png" style="height: 138px; width: 300px;"></p>
<p>给你树上某一个节点的标号 <code>label</code>,请你返回从根节点到该标号为 <code>label</code> 节点的路径,该路径是由途经的节点标号所组成的。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>label = 14
<strong>输出:</strong>[1,3,4,14]
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>label = 26
<strong>输出:</strong>[1,2,6,10,26]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= label &lt;= 10^6</code></li>
</ul>