🔥 JavaScript :  O(1) space,  O(n) time 🔥
We iteratively move from each node to the next node, while fixing the next pointers of their children. \n\nvar connect = function(root) {\n    let ptr = root;\n
We iteratively move from each node to the next node, while fixing the next pointers of their children. \n```\nvar connect = function(root) {\n    let ptr = root;\n    while(root && root.left){\n        let temp = root;\n        while(temp) {\n            temp.left.next = temp.right;\n            temp.right.next = temp.next ? temp.next.left : null;\n            temp = temp.next;\n        }\n        root = root.left;\n    }\n    return ptr;\n}\n```
['Iterator', 'JavaScript']