Skip to content

Instantly share code, notes, and snippets.

@tech-cow
Created October 17, 2018 05:21
Show Gist options
  • Select an option

  • Save tech-cow/4db6d5e3bf561de7a70e7c38e4478c63 to your computer and use it in GitHub Desktop.

Select an option

Save tech-cow/4db6d5e3bf561de7a70e7c38e4478c63 to your computer and use it in GitHub Desktop.
# n1 -> n2 -> n3
Class Node(self):
def __init__(self, val):
self.next = next
self.val = val
def reverse_list(self, head):
prev = None
cur = head
while cur:
next = cur.next
cur.next = prev
prev = cur
cur = next
return head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment