DDSA Solutions

Two Pointers

49 problems · 39 with full explanations

13 Easy29 Medium1 Hard
The two-pointer technique places pointers at different positions (often the two ends) and moves them toward each other. It turns O(n²) nested loops into O(n) sweeps for problems like pair sums, removing duplicates, and container capacity. Works best on sorted or partitioned arrays.

How to practice

To practice Two Pointers problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the two pointers pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.

Open the full study guide →

Start here (Easy + explained)

All Two Pointers problems