algorythms
All Patterns
Pattern 2

Two Pointers

135791113LR

Use two indices that move toward each other or in the same direction to solve problems on sorted arrays or when looking for pairs/triplets that satisfy a condition.

Time

O(n)

Space

O(1)

Recognize it when

  • Sorted array with pair/triplet sum problem
  • Remove duplicates in-place
  • Palindrome check
  • Partition or rearrange array in-place
Progress0/8
0 solved0 attempted