You are viewing a single comment's thread. Return to all comments →
I like you solution! Although your solution is likely a bit faster, I rewrote it so it is a bit more readable for some of us.
def Reverse(head): prev_node = None next_node = head while next_node: copy_prev_node = prev_node copy_next_next_node = next_node.next prev_node = next_node next_node.next = copy_prev_node next_node = copy_next_next_node head = prev_node return head
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a linked list
You are viewing a single comment's thread. Return to all comments →
I like you solution! Although your solution is likely a bit faster, I rewrote it so it is a bit more readable for some of us.