Linked Lists

Concept Lab
Python Execution SynchronizerActive Line: 1
1
def reverse_linked_list(head):
2
    prev = None
3
    curr = head
4
    
5
    while curr is not None:
6
        next_temp = curr.next
7
        curr.next = prev
8
        prev = curr
9
        curr = next_temp
10
        
11
    return prev
No execution event recorded.
Custom Input:
Loading trace state...
Step 0 / 0