@@ -0,0 +1,949 @@
+package leetcode.populating_next_right_pointers_in_each_node_ii;%0A%0Aimport common.TreeLinkNode;%0A%0Apublic class Solution %7B%0A%09public void connect(TreeLinkNode root) %7B%0A%09%09if(root == null) return;%0A%09%09TreeLinkNode parent = root;%0A%09%09if(parent.right != null)%7B%0A%09%09%09TreeLinkNode child = parent.right;%0A%09%09%09TreeLinkNode nxt = parent.next;%0A%09%09%09while(nxt != null)%7B%0A%09%09%09%09if(nxt.left != null)%7B%0A%09%09%09%09%09child.next = nxt.left;%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%09if(nxt.right != null)%7B%0A%09%09%09%09%09child.next = nxt.right;%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%09nxt = nxt.next;%0A%09%09%09%7D%0A%09%09%09connect(child);%0A%09%09%7D%0A%09%09%0A%09%09if(parent.left != null)%7B%0A%09%09%09TreeLinkNode child = parent.left;%0A%09%09%09TreeLinkNode nxt = parent.next;%0A%09%09%09if(parent.right != null)%7B%0A%09%09%09%09child.next = parent.right;%0A%09%09%09%7Delse%7B%0A%09%09%09%09while(nxt != null)%7B%0A%09%09%09%09%09if(nxt.left != null)%7B%0A%09%09%09%09%09%09child.next = nxt.left;%0A%09%09%09%09%09%09break;%0A%09%09%09%09%09%7D%0A%09%09%09%09%09if(nxt.right != null)%7B%0A%09%09%09%09%09%09child.next = nxt.right;%0A%09%09%09%09%09%09break;%0A%09%09%09%09%09%7D%0A%09%09%09%09%09nxt = nxt.next;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09connect(child);%0A%09%09%7D%0A%09%09%0A%09%7D%0A%7D%0A

Add java solution for 117. Populating Next Right Pointers in Each Node II