Skip to content

Commit 4d10895

Browse files
refactor 1104
1 parent 8ce241d commit 4d10895

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

src/main/java/com/fishercoder/solutions/_1104.java

+6-22
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,11 @@
1212
import java.util.List;
1313
import java.util.Queue;
1414

15-
/**
16-
* 1104. Path In Zigzag Labelled Binary Tree
17-
*
18-
* In an infinite binary tree where every node has two children, the nodes are labelled in row order.
19-
* In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right,
20-
* while in the even numbered rows (second, fourth, sixth,...), the labelling is right to left.
21-
*
22-
* 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.
23-
*
24-
* Example 1:
25-
* Input: label = 14
26-
* Output: [1,3,4,14]
27-
*
28-
* Example 2:
29-
* Input: label = 26
30-
* Output: [1,2,6,10,26]
31-
*
32-
* Constraints:
33-
* 1 <= label <= 10^6
34-
* */
3515
public class _1104 {
3616
public static class Solution1 {
37-
/**This brute force solution is correct but results in TLE on LeetCode.*/
17+
/**
18+
* This brute force solution is correct but results in TLE on LeetCode.
19+
*/
3820
public List<Integer> pathInZigZagTree(int label) {
3921
Deque<Integer> deque = buildZigZagOrderList(label);
4022
CommonUtils.printDeque(deque);
@@ -101,7 +83,9 @@ private Deque<Integer> buildZigZagOrderList(int label) {
10183
}
10284

10385
public static class Solution2 {
104-
/**We'll directly compute the index of its parent, it'll be much faster this way.*/
86+
/**
87+
* We'll directly compute the index of its parent, it'll be much faster this way.
88+
*/
10589
public List<Integer> pathInZigZagTree(int label) {
10690
List<List<Integer>> lists = buildZigZagOrderList(label);
10791
List<Integer> result = new ArrayList<>();

0 commit comments

Comments
 (0)