Tap here to switch tabs
Problem
Submissions

Problem: Path In Zigzag Labelled Binary Tree

med
30 min
Try to solve the Path In Zigzag Labelled Binary Tree problem.

Statement

In an infinite complete binary tree, nodes are labeled in a zigzag order across consecutive levels:

  • The first level contains the root with label 11.

  • The second level contains nodes labeled 33 to 22 from left to right.

  • The third level contains nodes labeled 44 to 77 from left to right.

  • The fourth level contains nodes labeled 1515 to 88 from left to right, and so on, reversing direction at each level.

Given the label of a node in this tree, return a list of labels representing the path from the root to the node with the given label.

Constraints:

  • 1≤label≤1061 \le label \le 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Path In Zigzag Labelled Binary Tree

med
30 min
Try to solve the Path In Zigzag Labelled Binary Tree problem.

Statement

In an infinite complete binary tree, nodes are labeled in a zigzag order across consecutive levels:

  • The first level contains the root with label 11.

  • The second level contains nodes labeled 33 to 22 from left to right.

  • The third level contains nodes labeled 44 to 77 from left to right.

  • The fourth level contains nodes labeled 1515 to 88 from left to right, and so on, reversing direction at each level.

Given the label of a node in this tree, return a list of labels representing the path from the root to the node with the given label.

Constraints:

  • 1≤label≤1061 \le label \le 10^6