/**
 * Definition for binary tree with next pointer.
 * public class TreeLinkNode {
 *     int val;
 *     TreeLinkNode left, right, next;
 *     TreeLinkNode(int x) { val = x; }
 * }
 */
public class Solution {
    public void connect(TreeLinkNode root) {
        if(root== null){
            return;
        }
        Queue<TreeLinkNode> queue = new LinkedList<>();
        queue.offer(root);
        while(!queue.isEmpty()){
            int levelSize = queue.size();
            for(int i=0;i<levelSize;i++){
                TreeLinkNode cur = queue.poll();
                if(i==levelSize-1){
                    cur.next = null;
                    if(cur.left!= null){}
                        queue.offer(cur.left);
                    }
                    if(cur.right != null){
                        queue.offer(cur.right);
                    }
                }else{
                    cur.next = queue.peek();
                    if(cur.left != null){
                        queue.offer(cur.left);
                    }
                    if(cur.right != null){
                        queue.offer(cur.right);
                    }
                }
            }

        }
        
    }
}
@@ -667,17 +667,16 @@
 = null)%7B
-%7D
 %0A       
@@ -1201,8 +1201,9 @@
 %0A    %7D%0A%7D
+%0A

Correct typing error