All patterns
Traversal & Pointer Manipulation
Linked Lists
Intermediate
Interactive
Reverse next pointers without losing the remaining chain.
Time
O(n)
Space
O(1)
ActiveComparingMatch / bestIn windowFrontierVisitedExcludedAnswer
No frames to display.
The idea
Linked lists store values in nodes connected by next pointers. Reversal walks the chain while redirecting each pointer toward the previous node, using three references to preserve both halves.
Analogy
A reusable way to think about organizing and navigating structured data efficiently.
When to reach for it
- The relationships between values drive the algorithm.
- You need efficient traversal, lookup, or updates.
- An interview problem names or implies this structure.
Language-independent template
prev = null
current = head
while current:
next = current.next
current.next = prev
prev = current
current = nextComplexity — time O(n), space O(1).
Common mistakes
- Losing a pointer before saving its next target.
- Breaking the structure invariant during an update.
- Forgetting empty and single-node cases.
Practice progression
Canonical interview problems, ordered from foundation to advanced application.
Easy
Reverse Linked ListLC 206
Reverse every next pointer in a singly linked list.
Medium
Reverse only the nodes between two positions.
Hard
Reverse complete groups of k nodes while preserving incomplete tails.
Variations
Traversal
Insertion and deletion
Search and reconstruction