mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -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
|
curr = head
|
||||||
|
|
||||||
while curr:
|
while curr:
|
||||||
next_temp = curr.next // save the pointer for the next node so we can continue the loop
|
next_temp = curr.next
|
||||||
curr.next = prev // revert the list
|
curr.next = prev
|
||||||
prev = curr // save for the next node revert
|
prev = curr
|
||||||
curr = next_temp // receive the pointer for the next node so we can continue the loop
|
curr = next_temp
|
||||||
|
|
||||||
return prev
|
return prev
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user