@@ -0,0 +1,1209 @@
+/**%0A * Definition for binary tree with next pointer.%0A * public class TreeLinkNode %7B%0A *     int val;%0A *     TreeLinkNode left, right, next;%0A *     TreeLinkNode(int x) %7B val = x; %7D%0A * %7D%0A */%0Apublic class Solution %7B%0A    public void connect(TreeLinkNode root) %7B%0A        if(root== null)%7B%0A            return;%0A        %7D%0A        Queue%3CTreeLinkNode%3E queue = new LinkedList%3C%3E();%0A        queue.offer(root);%0A        while(!queue.isEmpty())%7B%0A            int levelSize = queue.size();%0A            for(int i=0;i%3ClevelSize;i++)%7B%0A                TreeLinkNode cur = queue.poll();%0A                if(i==levelSize-1)%7B%0A                    cur.next = null;%0A                    if(cur.left!= null)%7B%7D%0A                        queue.offer(cur.left);%0A                    %7D%0A                    if(cur.right != null)%7B%0A                        queue.offer(cur.right);%0A                    %7D%0A                %7Delse%7B%0A                    cur.next = queue.peek();%0A                    if(cur.left != null)%7B%0A                        queue.offer(cur.left);%0A                    %7D%0A                    if(cur.right != null)%7B%0A                        queue.offer(cur.right);%0A                    %7D%0A                %7D%0A            %7D%0A%0A        %7D%0A        %0A    %7D%0A%7D

The solution for 116