Solved LeetCode program · 833 of 1,000
#1104 · Path In Zigzag Labelled Binary Tree
Original English source
The label is 14. The answers is an empty list of whole numbers. The node is label. Keep a shared base of 0. Keep a shared depth of 0.
To measure from value (a whole number). Set base to 1. Set depth to 0.
Repeat while base times 2 is at most value.
Set base to base times 2. Add 1 to depth.
Repeat while node is more than 0.
Place node into answers. Measure from node. The index is node minus base. The width is base minus 1. The mirror is width minus index. The parent is base divided by 2 plus mirror divided by 2. Set node to parent.
The spot is the last position of answers.
Repeat while spot is at least 0.
Show item spot of answers. Subtract 1 from spot.
Expected stdout
1 3 4 14