You are viewing a single comment's thread. Return to all comments →
def reverse(llist): # Write your code here if not llist: return None prev, curr = None, llist while curr: temp = curr.next curr.next = prev curr.prev = temp prev = curr curr = temp return prev
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a doubly linked list
You are viewing a single comment's thread. Return to all comments →
def reverse(llist): # Write your code here if not llist: return None prev, curr = None, llist while curr: temp = curr.next curr.next = prev curr.prev = temp prev = curr curr = temp return prev