Andita fahmi

This is just another blog to record my learning manifestation. Helpful only to me.

Learning For Technical Test: Sliding Window Problem

This week's learning is Sliding Window Problem. The characteristics of this problem topic are:

  1. 🔢Sequentialinput typically consists of strings or arrays, such ase []int or string.
    The problem is asking about continuous segments, not scattered elements.
  2. ⏱️Fixed or variable-length window; You're asked to identify or improve something over a range that moves:
    • "Find all substrings of length 10…"
    • Variable: "Find the smallest subarray whose sum is greater than or equal to the target."
  3. 🔄If you used a brute-force method, you wouldneed to check the overlapping parts again during repeated calculations over ranges; however, the sliding window technique avoids this by updating values instead of recalculating them.
  4. 📊 Aggregate property—this is how you keep track of things like:
    • Inside the window, you can see the sum, count, frequency, or max/min.
    • For example, "max sum of k elements" or "count of distinct chars ≤ k."
  5. 🚫 The window only moves forward, so you don't have to go back.
  6. ⚖️ Often means keeping things in balance or under control, like:
    • "At most k different characters."
    • "Sum less than target."