mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 12:16:14 -04:00
Update reverse_linked_list_II.py
This commit is contained in:
parent
b16196e810
commit
60b5ec4a88
@ -18,10 +18,10 @@ def reverse_list(head: Optional[Node]) -> Optional[Node]:
|
||||
curr = head
|
||||
|
||||
while curr:
|
||||
next_temp = curr.next // save the pointer for the next node so we can continue the loop
|
||||
curr.next = prev // revert the list
|
||||
prev = curr // save for the next node revert
|
||||
curr = next_temp // receive the pointer for the next node so we can continue the loop
|
||||
next_temp = curr.next
|
||||
curr.next = prev
|
||||
prev = curr
|
||||
curr = next_temp
|
||||
|
||||
return prev
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user