You are viewing a single comment's thread. Return to all comments →
Another, more Pythonic way:
def reverse(head): curr = new_head = head while curr: curr.prev, curr.next = curr.next, curr.prev new_head = curr curr = curr.prev return new_head
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 →
Another, more Pythonic way: