visualization
Linked List Reversal
Three pointers, one flip per node, zero extra memory.
list = 3 → 7 → 1 → 9 → 4 · reverse in placestep 1/17
Start: every arrow points right, head is 3. prev is None and cur sits on 3.
pseudocode
prev = Nonecur = headwhile cur:next = cur.next # save the escape routecur.next = prev # flip the arrowprev, cur = cur, nextreturn prev # new head