Skip to content

Commit 36de3ae

Browse files
refactor 117
1 parent ba3c504 commit 36de3ae

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727

2828
public class _117 {
2929
public static class Solution1 {
30-
//copied this post: https://discuss.leetcode.com/topic/1106/o-1-space-o-n-complexity-iterative-solution
31-
//very clever and concise to make it in O(1) space
32-
33-
//based on level order traversal
30+
/**credit: https://discuss.leetcode.com/topic/1106/o-1-space-o-n-complexity-iterative-solution
31+
O(1) space, based on level order traversal*/
3432
public void connect(TreeLinkNode root) {
3533

3634
TreeLinkNode head = null; //head of the next level
@@ -69,4 +67,4 @@ public void connect(TreeLinkNode root) {
6967
}
7068
}
7169
}
72-
}
70+
}

src/test/java/com/fishercoder/_117Test.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66
import org.junit.Test;
77

88
public class _117Test {
9-
private static _117.Solution1 solution1;
10-
private static TreeLinkNode root;
9+
private static _117.Solution1 solution1;
10+
private static TreeLinkNode root;
1111

12-
@BeforeClass
13-
public static void setup() {
14-
solution1 = new _117.Solution1();
15-
}
12+
@BeforeClass
13+
public static void setup() {
14+
solution1 = new _117.Solution1();
15+
}
1616

17-
@Test
18-
public void test1() {
19-
root = new TreeLinkNode(1);
20-
root.left = new TreeLinkNode(2);
21-
root.right = new TreeLinkNode(3);
22-
root.left.left = new TreeLinkNode(4);
23-
root.left.right = new TreeLinkNode(5);
24-
root.right.right = new TreeLinkNode(7);
17+
@Test
18+
public void test1() {
19+
root = new TreeLinkNode(1);
20+
root.left = new TreeLinkNode(2);
21+
root.right = new TreeLinkNode(3);
22+
root.left.left = new TreeLinkNode(4);
23+
root.left.right = new TreeLinkNode(5);
24+
root.right.right = new TreeLinkNode(7);
2525

26-
solution1.connect(root);
27-
}
28-
29-
}
26+
solution1.connect(root);
27+
}
28+
}

0 commit comments

Comments
 (0)