Simple recursive Java solution O(1) space O(n) time
public void connect(TreeLinkNode root) {\n        \n        if(root==null) return ;\n        \n        link(root.left,root.right);\n    }\n    \n    //HELPER FU
    public void connect(TreeLinkNode root) {\n        \n        if(root==null) return ;\n        \n        link(root.left,root.right);\n    }\n    \n    //HELPER FUNCTION TO LINK TWO NODES TOGETHER\n    public void link(TreeLinkNode left, TreeLinkNode right){\n        \n        if(left==null && right==null) return ;\n        \n        left.next = right;\n        link(left.left,left.right);\n        link(left.right,right.left);\n        link(right.left,right.right);\n    }
['Recursion', 'Java']