1104. Path In Zigzag Labelled Binary Tree Medium
1/**
2 * [1104] Path In Zigzag Labelled Binary Tree
3 *
4 * In an infinite binary tree where every node has two children, the nodes are labelled in row order.
5 * 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.
6 * <img alt="" src="https://assets.leetcode.com/uploads/2019/06/24/tree.png" style="width: 300px; height: 138px;" />
7 * Given the label of a node in this tree, return the labels in the path from the root of the tree to the node with that label.
8 *
9 * Example 1:
10 *
11 * Input: label = 14
12 * Output: [1,3,4,14]
13 *
14 * Example 2:
15 *
16 * Input: label = 26
17 * Output: [1,2,6,10,26]
18 *
19 *
20 * Constraints:
21 *
22 * 1 <= label <= 10^6
23 *
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/
28// discuss: https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33 pub fn path_in_zig_zag_tree(label: i32) -> Vec<i32> {
34 vec![]
35 }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_1104() {
46 }
47}
48
Back
© 2025 bowen.ge All Rights Reserved.