@@ -0,0 +1,1162 @@
+package problems;%0A%0Apublic class PopulatingNextRightPointers2 %7B%0A%0A    // Definition for binary tree with next pointer.%0A    public class TreeLinkNode %7B%0A        int val;%0A        TreeLinkNode left, right, next;%0A%0A        TreeLinkNode(int x) %7B%0A            val = x;%0A        %7D%0A    %7D%0A%0A    public void connect(TreeLinkNode root) %7B%0A        TreeLinkNode cur = root, subRow = null, subp = null;%0A        while (cur != null) %7B%0A            if (cur.left != null) %7B%0A                if (subRow == null) %7B%0A                    subRow = cur.left;%0A                    subp = subRow;%0A                %7D else %7B%0A                    subp.next = cur.left;%0A                    subp = subp.next;%0A                %7D%0A            %7D%0A            if (cur.right != null) %7B%0A                if (subRow == null) %7B%0A                    subRow = cur.right;%0A                    subp = subRow;%0A                %7D else %7B%0A                    subp.next = cur.right;%0A                    subp = subp.next;%0A                %7D%0A            %7D%0A            if (cur.next != null)%0A                cur = cur.next;%0A            else %7B%0A                cur = subRow;%0A                subRow = null;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add Populating Next Right Pointer 2