Skip to content

02. Arrays

🧠 Arrays Strategy

  • Prefix Sum: Use when querying sums in a range multiple times O(1).
  • Carry Forward: Track "max so far" or "min so far" to solve in O(N).
  • Two Pointers: Great for finding pairs in sorted arrays or trapping water.
  • Binary Search: Look for the Search Space. Is it the array index? Or is it the answer itself (Binary Search on Answer)?

🟢 Basics & Prefix Sum

🟡 Subarrays & Carry Forward

🟠 2D Matrices

🟣 Two Pointers & Swaps

🔴 Binary Search on Answer


📚 Other Problems