ATLAS / CHAPTER 01
THE INSPECTION RAIL

TWO
POINTERS.

03PROBLEMS

Two positions. One reason to move.
Learn what you can safely leave behind.

Don’t ask “which pointer moves?” Ask “what can this move safely rule out?”

Start at two useful positions. Inspect what they tell you. Move a boundary only when you can explain why the discarded work cannot change the answer.

For a palindrome, matched edges are settled. For water, the shorter wall is a ceiling. For 3Sum, sorted order gives each move a direction.

WATCH THE INVARIANT01 / 03
a0Lb1c2a3ROUTSIDE: VERIFIED / INSIDE: STILL A QUESTION
PAIRS0
COMPARISONmatch

Everything outside these pointers has been verified. The inside is still undecided.

YOUR TURN · PREDICT THE MOVE

These two characters match. What have we proved?

CHECK THE IDEA

The outside letters of “abca” match. Can we stop?

01
The inspection rail

Valid Palindrome

Match the edges. Keep the middle honest.

6 min
02
The limiting wall

Container With Most Water

Discover what you can safely leave behind.

03
Pin and steer

3Sum

Pin one value. Let order guide the others.

THE BRIDGE TO 3SUM · 60 SECONDS

Give movement a direction.

In sorted values, moving left forward makes its value larger or equal. Moving right backward makes its value smaller or equal.

−5−2035

Pin −5. The other values are −2 and 5. The total is −2. Which move can raise it?