Python, constant space
Use the already-populated next pointers of the row above to fill the row below:\n\ndef connect(self, root: \'Node\') -> \'Node\':\n\tif not root: return\n\t\n\t
Use the already-populated next pointers of the row above to fill the row below:\n```\ndef connect(self, root: \'Node\') -> \'Node\':\n\tif not root: return\n\t\n\tabove, below = root, root.left\n\twhile below:\n\t\tcur = below\n\t\twhile above:\n\t\t\tif cur == above.left:\n\t\t\t\tcur.next = above.right\n\t\t\t\tabove = above.next\n\t\t\telse:\n\t\t\t\tcur.next = above.left\n\t\t\tcur = cur.next\n\n\t\tabove = below\n\t\tbelow = below.left\n\n\treturn root\n```
['Python', 'Python3']