mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 23:11:41 +08:00
update
This commit is contained in:
29
leetcode/problem/path-in-zigzag-labelled-binary-tree.html
Normal file
29
leetcode/problem/path-in-zigzag-labelled-binary-tree.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<p>In an infinite binary tree where every node has two children, the nodes are labelled in row order.</p>
|
||||
|
||||
<p>In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right, while in the even numbered rows (second, fourth, sixth,...), the labelling is right to left.</p>
|
||||
|
||||
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/06/24/tree.png" style="width: 300px; height: 138px;" /></p>
|
||||
|
||||
<p>Given the <code>label</code> of a node in this tree, return the labels in the path from the root of the tree to the node with that <code>label</code>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> label = 14
|
||||
<strong>Output:</strong> [1,3,4,14]
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> label = 26
|
||||
<strong>Output:</strong> [1,2,6,10,26]
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= label <= 10^6</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user