Skip to content

Commit 3fa4585

Browse files
refactor 117
1 parent 1228e14 commit 3fa4585

File tree

1 file changed

+4
-25
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+4
-25
lines changed

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

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,12 @@
22

33
import com.fishercoder.common.classes.TreeLinkNode;
44

5-
/**
6-
* 117. Populating Next Right Pointers in Each Node II
7-
*
8-
* Follow up for problem "Populating Next Right Pointers in Each Node".
9-
* What if the given tree could be any binary tree? Would your previous solution still work?
10-
11-
Note:
12-
13-
You may only use constant extra space.
14-
For example,
15-
Given the following binary tree,
16-
1
17-
/ \
18-
2 3
19-
/ \ \
20-
4 5 7
21-
After calling your function, the tree should look like:
22-
1 -> NULL
23-
/ \
24-
2 -> 3 -> NULL
25-
/ \ \
26-
4-> 5 -> 7 -> NULL */
27-
285
public class _117 {
296
public static class Solution1 {
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*/
7+
/**
8+
* credit: https://discuss.leetcode.com/topic/1106/o-1-space-o-n-complexity-iterative-solution
9+
* O(1) space, based on level order traversal
10+
*/
3211
public void connect(TreeLinkNode root) {
3312

3413
TreeLinkNode head = null; //head of the next level

0 commit comments

Comments
 (0)