whoashish's cp notes

Home

❯

3. Array Techniques

3. Array Techniques

Oct 08, 20261 min read

  • i. Prefix Sums and Difference Arrays: Prefix sums give O(1) range queries on a static array.
  • ii. Two Pointers and Sliding Window: Keep a window [l,r] whose ends only move forward.
  • iii. Monotonic Stack: A stack kept sorted answers “nearest element to the left/right that is smaller/greater” for every position in O(n) total.
  • iv. Classic Array Problems: Short problems with techniques that transfer:
  • v. Subarray Aggregates and Mex: Two families of “over all subarrays” problems.

5 items under this folder.

  • Oct 08, 2026

    ii. Two Pointers and Sliding Window

    • arrays
    • two-pointers
  • Oct 08, 2026

    i. Prefix Sums and Difference Arrays

    • arrays
    • prefix-sums
  • Oct 08, 2026

    iii. Monotonic Stack

    • arrays
    • stack
  • Oct 08, 2026

    iv. Classic Array Problems

    • arrays
    • classics
  • Oct 08, 2026

    v. Subarray Aggregates and Mex

    • arrays
    • gcd
    • mex