Skip to main content

LL Vis

Pointer Logic

Initializing LinkedList Canvas...

1x
Algorithm Details
Best Time
Ω(n)
Worst Time
O(n)
Aux Space
Θ(n)
Algorithm Logic
1Algorithm Reverse(head):
2 Set prev = null, curr = head
3 While curr is not null:
4 next = curr.next
5 curr.next = prev
6 prev = curr
7 curr = next
8 Return prev (new head)