DSA Master › Topic 2

Two Pointers

Two indices move through the data according to a rule, so you avoid nested loops. On sorted input, comparing the two ends tells you which pointer to move.

Concepts

How to recognise it

Common pitfalls

Problems

  1. Valid Palindrome (Easy)
  2. Two Sum II – Input Array Is Sorted (Medium)
  3. 3Sum (Medium)
  4. 4Sum (Medium)
  5. Container With Most Water (Medium)
  6. Trapping Rain Water (Hard)
  7. Remove Duplicates from Sorted Array (Easy)
  8. Sort Colors (Medium)
  9. Move Zeroes (Easy)