[JAVA] O(1) Memory Solution (Recursive + Iterative) - Faster than 100%
1. Recurisve\n\nclass Solution {\n    public Node connect(Node root) {\n        if(root == null)\n            return root;\n        if(root.left != null){\n    
**1. Recurisve**\n```\nclass Solution {\n    public Node connect(Node root) {\n        if(root == null)\n            return root;\n        if(root.left != null){\n            if(root.next != null)\n                root.right.next = root.next.left;\n            else\n                root.right.next = null;\n            root.left.next = root.right;\n            connect(root.left);\n            connect(root.right);\n        }\n        return root;\n    }\n}\n```\n\n**2. Iterative**\n```\nclass Solution {\n    public Node connect(Node root) {\n        Node leftest = root;\n        while(leftest != null && leftest.left != null) {\n        \tNode curr = leftest;\n        \twhile(true) {\n        \t\tcurr.left.next = curr.right;\n        \t\tif(curr.next != null)\n        \t\t\tcurr.right.next = curr.getNextSibling().left;\n        \t\telse\n        \t\t\tbreak;\n        \t}\n        \tcurr = curr.left;\n        }\n        return root;\n    }\n}\n```
['Java']