package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/
 */
public class Problem1104 {
    public List<Integer> pathInZigZagTree(int label) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1104 prob = new Problem1104();
        System.out.println(prob.pathInZigZagTree(14)); // [1,3,4,14]
        System.out.println(prob.pathInZigZagTree(26)); // [1,2,6,10,26]
    }
}

@@ -12,16 +12,74 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Collections;%0A
 import j
@@ -93,16 +93,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -266,275 +266,418 @@
     
-// TODO%0A        return null
+int level = (int) (Math.log10(label) / Math.log10(2))
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1104 prob = new Problem1104();%0A        System.out.println(prob.pathInZigZagTree(14)); // %5B1,3,4,14%5D%0A        System.out.println(prob.pathInZigZagTree(26)); // %5B1,2,6,10,26%5D
+List%3CInteger%3E answer = new ArrayList%3C%3E();%0A        while (label != 0) %7B%0A            answer.add(label);%0A            int left = (int) Math.pow(2, level - 1);%0A            int right = (int) Math.pow(2, level) - 1;%0A            label = left + (right - label / 2);%0A            level--;%0A        %7D%0A        Collections.reverse(answer);%0A        return answer;
 %0A   

Solve problem 1104