1. Ordered Window

    Ordered Window When To Use Use this when the active window needs ordered queries like min, max, median, or closest value.

  2. Prefix Sum Hashmap

    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.

  3. Rolling Hash String Matching

    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.

  4. Shrink While Valid

    Shrink While Valid Template Use this when you need the smallest valid window.

  5. Variable Size Maintain Invariant

    Variable Size: Maintain Invariant My bias in Max Consecutive Ones III I simulated the operation instead of maintaining an invariant.

  6. Fast Slow Pointer

    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.

  7. Merge Sorted Sources

    Merge Sorted Sources When To Use Use this when consuming two sorted arrays, lists, or interval streams.

  8. Opposite Ends

    Opposite Ends When To Use Use this when two pointers start at opposite ends and each move has a local reason to discard one side.

  9. Partition Around Pivot

    Partition Around Pivot When To Use Use this when separating values into groups in-place.

  10. Same Direction Read Write

    Same Direction Read Write When To Use Use this when compacting, filtering, overwriting, or partitioning in-place.