Another accepted Java solution
Basically, we use the next pointer to help level traversal. No recursion is needed, O(1) constant space, O(n) running time.\n\n    public class Solution {\n    
Basically, we use the next pointer to help level traversal. No recursion is needed, O(1) constant space, O(n) running time.\n\n    public class Solution {\n        public void connect(TreeLinkNode root) {\n            if (root == null) return;\n            \n            while (root.left != null) {\n                TreeLinkNode curr = root;\n                \n                while (curr != null) {\n                    curr.left.next = curr.right;\n                    curr.right.next = curr.next != null ? curr.next.left : null;\n                    curr = curr.next;\n                }\n                \n                root = root.left;\n            }\n        }\n    }
['Java']