← All patterns
11 / 32
Stacks, Queues & Heaps

Linked List

When you see it

Signal words

If the prompt uses any of these, this pattern should come to mind first.

reverse listcyclemiddle nodenth from endmerge listsfast & slow
Practice

Drill this pattern with an AI trainer — reply only with Hint, Next, Lost, or paste your code.

Ask yourself

  1. Pointer surgery on nodes (reverse, reorder)?
  2. Cycle / middle → fast & slow pointers.
  3. A dummy head simplifies edge cases.

Classic problem

Reverse Linked List (LeetCode 206) — reverse a singly linked list and return the new head. Walk forward, flipping each next pointer to point back at the node behind it.

Input: head = [1, 2, 3, 4, 5]

Output: [5, 4, 3, 2, 1] — each node’s .next pointer is reversed in a single pass.

Watch it run

Common pitfalls

Losing the rest of the list by reassigning .next too early.

Null-deref on the final node.