AlgoScope

Three Sum

AlgorithmintermediateTwo Pointers

Fix one element, run two-sum on the rest; skip duplicates.

Decision · step 3 of 13Two Pointer Problems: Three sum to zero
active 2-5-40-11-12031425ileftright

-4 + -1 + 2 = -3, short of 0. Only a bigger left value can help, so left moves up.

Open in the player →or start at step 3

What you will see

An anchor pointer walks; for each anchor the inner pair converges.

How two pointer problems works →

Cost

BestO(n^2)
AverageO(n^2)
WorstO(n^2)
SpaceO(1)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.

Screen readers: Pointers announce their name and index; each step announces which pointer moved and why.

Reduced motion: Pointers appear at their new index with a brief emphasis instead of gliding.

Taught by the same lesson

Two Pointer Problems covers these too, in the same run.