Guided lesson

Two Pointer Pattern

Patterns

Two Pointer Pattern

Practice pattern

Mental model

  • Often requires sorted input.

Operations

left++

Cost shape

Usually O(n)

Watch out

Moving the wrong pointer.

Related algorithms

Two Sum SortedPalindrome Check
Guided progression
10% lesson
Step 1 / 2Learner goal
Speech settings Speed 1.0 · Volume 90%

Keyboard: Space play/pause · Arrow keys step · Page Up/Down change sections · R restart