Linked List: Pointer rewiring and fast/slow pointers
Goal: Learn the pattern first, then apply it to the 12 roadmap problems in this chapter.
When this pattern appears
The task asks to reorder, reverse, detect a cycle, or compare nodes without indexing.
The reusable idea
Save next pointers before rewiring. Dummy nodes simplify head changes; fast/slow pointers create offsets.
A deliberate problem-solving routine
- Write the input and output in plain language. Identify whether order, duplicates, or mutation matter.
- Work a tiny example by hand; label the state you wish you had at each step.
- Choose the structure or invariant that stores that state.
- Establish a brute-force baseline, then show exactly which repeated work the pattern removes.
- State the invariant before the loop, after each iteration, and at termination.
- Test smallest, boundary, duplicate, and adversarial cases.
Watch the animated pattern
The diagram above this lesson animates the core state changes for this chapter. Use pause and step to predict what moves next. The same invariant should explain each application, even when the problem story changes.
Questions to ask yourself
Which nodes do the pointers represent before and after each link change?
Common failure modes
Null checks, preserving the remaining list, cycle creation, and odd/even lengths.
Chapter problems from the workbook
- #39 · Reverse Linked List — Day 23, Easy. Open problem ↗
- #40 · Merge Two Sorted Lists — Day 23, Easy. Open problem ↗
- #41 · Linked List Cycle — Day 23, Easy. Open problem ↗
- #42 · Palindrome Linked List — Day 24, Easy. Open problem ↗
- #43 · Reorder List — Day 24, Medium. Open problem ↗
- #44 · Remove Nth Node From End of List — Day 25, Medium. Open problem ↗
- #45 · Find the Duplicate Number — Day 25, Medium. Open problem ↗
- #46 · Add Two Numbers — Day 26, Medium. Open problem ↗
- #47 · Copy List with Random Pointer — Day 26, Medium. Open problem ↗
- #48 · LRU Cache — Day 27, Medium. Open problem ↗
- #49 · Merge K Sorted Lists — Day 27, Hard. Open problem ↗
- #50 · Reverse Nodes in K-Group — Day 29, Hard. Open problem ↗
Interview explanation
A concise explanation has four parts: the key observation, the maintained invariant, why each step preserves it, and the time/space complexity. Avoid naming a pattern as a substitute for proving the step is safe.