Skip to content

Two Pointers

Instead of a loop inside a loop, put one finger at each end (or one slow and one fast finger) and move them toward each other based on a simple rule. Each move throws away candidates you can prove are useless, so you finish in one pass.

After this topic: You can decide which pointer to move and justify why the discarded options can never be the answer.

Do these first: Arrays & Hashing

0 of 5 solved0%

Step 1 · Read the lesson

Two Pointers

Walk two indexes through sorted or symmetric data instead of nesting loops.

Step 2 · Solve the problems in order

Try each one for about 20 minutes first. Problems with a Run code tab are checked right here. If you are stuck, open Nudge, think again, then Idea. Go skeleton only gives the function shape, and Reference solution is for comparing after you have tried. Tick the box when you could solve it again without help.

  1. 3.3Sum Medium

Step 3 · What this unlocks