Accepted Java recursive solution
The recursive solution of my last post, although the space is not O(1) (due to recursion), the solution is still elegant.\n\n    public class Solution {\n      
The recursive solution of my last post, although the space is not O(1) (due to recursion), the solution is still elegant.\n\n    public class Solution {\n        public void connect(TreeLinkNode root) {\n            if (root == null) return;\n            \n            if (root.left != null) {\n                root.left.next = root.right;\n            }\n            \n            if (root.right != null) {\n                root.right.next = root.next != null ? root.next.left : null;\n            }\n            \n            connect(root.left);\n            connect(root.right);\n        }\n    }
['Java']