Histogram Expansion
Histogram Expansion When To Use Use this when choosing an index as the minimum height/value and expanding as far as possible improves the objective.
Histogram Expansion When To Use Use this when choosing an index as the minimum height/value and expanding as far as possible improves the objective.
Exactly K via At Most Template Use this when counting subarrays/substrings with exactly k of something.
Fixed Size Window Template Use this when every candidate window must have exactly size k.
Last Seen Jump Left When To Use Use this when duplicates can be handled by jumping l directly instead of removing one element at a time.
Ordered Window When To Use Use this when the active window needs ordered queries like min, max, median, or closest value.
Prefix Sum + Hashmap When To Use Use this instead of sliding window when the array can contain negative numbers or the target condition is not monotonic.
Rolling Hash / String Matching Window When To Use Use this when every window has fixed length, but comparing raw strings or full frequency arrays would be too expensive.
Shrink While Valid Template Use this when you need the smallest valid window.
Variable Size: Maintain Invariant My bias in Max Consecutive Ones III I simulated the operation instead of maintaining an invariant.
Fast Slow Pointer Intuition Both pointer will move through the non-cycle part, then once inside the cycle, they have a relative speed of one for covering the gap between them so in ācā steps they will definitely meet.