JAVA Solution | 10 lines code | O(n) Time and Constant space
Idea here to take advantage of already set values of next. When going to child, parent will already have their next value. We can take advantage of that. This i
Idea here to take advantage of already set values of next. When going to child, parent will already have their next value. We can take advantage of that. This is the minimize solution.\n\n```\npublic Node connect(Node root) {\n        if(root == null) return root;\n        modify(root);\n        \n        return root;\n    }\n    public void modify(Node root){\n        if(root.left == null && root.right == null){\n            return;\n        }\n        root.left.next = root.right;\n        if(root.next !=null ){\n            root.right.next = root.next.left;    \n        }\n        modify(root.left);\n        modify(root.right);  \n    }\n```
[]