Skip to content

Instantly share code, notes, and snippets.

@JasonGideon
Created March 25, 2019 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonGideon/716a1b5c37e0e988bad74fc064247144 to your computer and use it in GitHub Desktop.
Save JasonGideon/716a1b5c37e0e988bad74fc064247144 to your computer and use it in GitHub Desktop.
class Solution:
def connect(self, root):
"""
:type root: TreeLinkNode
:rtype: nothing
"""
if not root:
return
pre = root
while root.left:
root.left.next = root.right
if root.next:
root.right.next = root.next.left
root = root.next
else:
root = pre.left
pre = root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment