Skip to content

Instantly share code, notes, and snippets.

@imedadel
Created November 4, 2019 15:40
Show Gist options
  • Save imedadel/32851aeddd7b60930a67305ac8efabd7 to your computer and use it in GitHub Desktop.
Save imedadel/32851aeddd7b60930a67305ac8efabd7 to your computer and use it in GitHub Desktop.
def reverse(head):
curr = new_head = head
while curr:
print(curr.data)
curr.prev, curr.next = curr.next, curr.prev
new_head = curr
curr = curr.prev
return new_head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment