intro practice · coding problem
Reverse a linked list in place
Reverse singly linked list 1→2→3→null iteratively. Return new head.
The mechanism
A linked list trades fast random access for fast inserts and deletes wherever you already have a pointer. The classic moves: a dummy head to simplify edge cases, two pointers (fast and slow), and reversing in place.
Expected evidence
3→2→1→null.
Try this drill in the practice workspace →
Hints when you need them
- Keep prev, curr, next pointers.
- Dummy head simplifies inserts elsewhere.