4 patterns · 20 problems

Linked List

Pointer choreography — fast/slow runners, dummy heads, recursion, and in-place reversal.

Each pattern below starts with when to reach for it and the clue in the prompt that gives it away. Then it runs on real problems: pick one to watch the technique step by step, open its full solution, or practise it on an original problem with graded tests.

01Pattern

Fast and Slow Pointers

Two runners at different speeds expose cycles and midpoints.

This patternO(1) spacenaïve O(n) space

When to reach for it

  • You have a problem where you need to find pairs of elements that meet certain conditions, such as the midpoint of the linked list, detecting cycles, or removing specific elements.

Spot it in the prompt

Look for problems that involve traversing the linked list efficiently using two pointers simultaneously, often requiring pointer manipulation or comparison.

Easy Custom animation

Linked List Cycle

LeetCode(opens in a new tab)
Loading animation…

How to solve it

Move slow by one and fast by two; if they ever meet a cycle exists, otherwise fast reaches null.

Practice · 6 problems

Pick a problem to watch the technique run on it. A sparkle icon marks a problem with its own custom animation, and a code icon one you can practise here with graded tests.

02Pattern

Dummy Node Technique

A placeholder head erases messy edge cases.

When to reach for it

  • You need to simplify edge cases, such as handling an empty list or adding/removing elements at the beginning.

Spot it in the prompt

Problems often involve scenarios where dealing with the head of the linked list is cumbersome or requires special treatment.

Medium

Add Two Numbers

LeetCode(opens in a new tab)
Loading animation…

How to solve it

Animation shows the Dummy Node Technique technique

Traverse both lists adding digits plus carry, appending each sum node after a dummy head to simplify list construction.

Odometer Tape Sum is our own problem on the same technique: a new statement, graded in your browser.

Practice · 4 problems

Pick a problem to watch the technique run on it. A sparkle icon marks a problem with its own custom animation, and a code icon one you can practise here with graded tests.

03Pattern

Recursion Technique

Let the call stack walk the list for you.

When to reach for it

  • Solving problems that require traversal or manipulation of the linked list structure in a recursive manner.

Spot it in the prompt

Look for problems where a recursive approach provides an elegant solution, such as dividing it into subproblems.

Medium

Swap Nodes in Pairs

LeetCode(opens in a new tab)
Loading animation…

How to solve it

Animation shows the Recursion Technique technique

Recursively swap the first two nodes, then point the first at the result of swapping the remaining list.

Swap Neighbouring Clips is our own problem on the same technique: a new statement, graded in your browser.

Practice · 4 problems

Pick a problem to watch the technique run on it. A sparkle icon marks a problem with its own custom animation, and a code icon one you can practise here with graded tests.

04Pattern

In-Place Reversal Technique

Rewire next pointers to reverse without extra space.

This patternO(1) spacenaïve O(n) space

When to reach for it

  • You need to reverse the linked list in-place without using extra space, typically by modifying the pointers iteratively.

Spot it in the prompt

Problems where you're asked to reverse the linked list or perform operations on segments without using additional data structures.

Easy

Reverse Linked List

LeetCode(opens in a new tab)
Loading animation…

How to solve it

Animation shows the In-Place Reversal Technique technique

Iterate with prev, curr, and next pointers, redirecting each node's next to prev and advancing until the list is reversed.

Rewind the Telemetry Chain is our own problem on the same technique: a new statement, graded in your browser.

Practice · 6 problems

Pick a problem to watch the technique run on it. A sparkle icon marks a problem with its own custom animation, and a code icon one you can practise here with graded tests.

After the pattern

Now solve one you haven't seen.

Reading a pattern isn't the same as using it. The practice set has 1,194 original problems on the same techniques, each graded in your browser.

1,194 problems · 15,062 graded tests · free