Skip to content

Commit c963241

Browse files
116. Populating Next Right Pointers in Each Node (java)
1 parent a879238 commit c963241

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public void connect(TreeLinkNode root) {
3+
if (root == null || root.left == null) return;
4+
root.left.next = root.right;
5+
if (root.next == null) root.right.next = null;
6+
else root.right.next = root.next.left;
7+
connect(root.left);
8+
connect(root.right);
9+
}
10+
}

0 commit comments

Comments
 (0)