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 a879238 commit c963241Copy full SHA for c963241
solution/0116.Populating Next Right Pointers in Each Node/Solution.java
@@ -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