0PricingLogin
Competitive Programming Academy · Lesson

Two Pointers on a Sorted Array

Move ends inward to meet a target.

Why Two Pointers

The two-pointer technique scans an array with two indices instead of nested loops, turning many O(n^2) ideas into a single clean O(n) pass. 🎯

Sorted Is the Magic Word

The classic version needs a sorted array. Order lets you reason: moving right grows the value, moving left shrinks it, so each step is a real decision.

All lessons in this course

  1. Two Pointers on a Sorted Array
  2. Find a Pair with a Given Sum
  3. Remove Duplicates In Place
  4. Merge Two Sorted Sequences
← Back to Competitive Programming Academy