We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a9f413 commit 32539c2Copy full SHA for 32539c2
(#117)PopulatingNextRightPointersinEachNodeII/PopulatingNextRightPointersinEachNodeII.java
@@ -0,0 +1,20 @@
1
+public class Solution {
2
+ public void connect(TreeLinkNode root) {
3
+ while(root != null){
4
+ TreeLinkNode start = new TreeLinkNode(0);
5
+ TreeLinkNode pointer = start;
6
7
+ if(root.left != null){
8
+ pointer.next = root.left;
9
+ pointer = pointer.next;
10
+ }
11
+ if(root.right != null){
12
+ pointer.next = root.right;
13
14
15
+ root = root.next;
16
17
+ root = start.next;
18
19
20
+}
0 commit comments