From 60b5ec4a8812eed9cc27561da2c0f942c71a5c9c Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:51:00 -0700 Subject: [PATCH] Update reverse_linked_list_II.py --- linked_lists/reverse_linked_list_II.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linked_lists/reverse_linked_list_II.py b/linked_lists/reverse_linked_list_II.py index 0692312..281a031 100644 --- a/linked_lists/reverse_linked_list_II.py +++ b/linked_lists/reverse_linked_list_II.py @@ -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 - +