Sliding Window mind map
Maintain a window over arrays and strings.
Core idea: Contiguous range + incremental add/remove + repairable validity equals a window.
Mnemonic: Expand → repair → record · Cost: O(n) · each endpoint moves once
Fix: Constant width
Signal: Every candidate range has the same known length.
Move: Add the entering value, remove the leaving value, and record after the window reaches size k.
Examples: Maximum Average, Moving Average, Anagram Indices
Satisfy: Minimum valid window
Signal: The range must cover a required set or reach a threshold.
Move: Expand until valid, then shrink while validity survives to expose the minimum.
Examples: Minimum Window Substring, Minimum Size Subarray, Fruit Baskets
Limit: Longest valid window
Signal: A budget, distinct count, or replacement rule can be repaired from the left.
Move: Shrink only while over budget; record the largest valid width after repair.
Examples: Longest Unique Substring, Character Replacement, At Most K Distinct
Extreme: Window maximum/minimum
Signal: Each window asks for an extreme but recomputing it would be too slow.
Move: Keep a monotonic deque of useful indices; expire the front as the window moves.
Examples: Sliding Window Maximum, Shortest Subarray, Constrained Subsequence