File tree 2 files changed +20
-23
lines changed
main/java/com/fishercoder/solutions
test/java/com/fishercoder 2 files changed +20
-23
lines changed Original file line number Diff line number Diff line change 27
27
28
28
public class _117 {
29
29
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*/
34
32
public void connect (TreeLinkNode root ) {
35
33
36
34
TreeLinkNode head = null ; //head of the next level
@@ -69,4 +67,4 @@ public void connect(TreeLinkNode root) {
69
67
}
70
68
}
71
69
}
72
- }
70
+ }
Original file line number Diff line number Diff line change 6
6
import org .junit .Test ;
7
7
8
8
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 ;
11
11
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
+ }
16
16
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 );
25
25
26
- solution1 .connect (root );
27
- }
28
-
29
- }
26
+ solution1 .connect (root );
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments