1. Fixed Window Extrema

    Fixed Window Extrema When To Use Use this when every query is over a fixed-size window and you need the max or min.

  2. Prefix Sum Candidates

    Prefix Sum Candidates When To Use Use this when candidates are prefix indices and the deque keeps the best prefix sums.

  3. Variable Window Max Min

    Variable Window Max Min When To Use Use this when a variable-size window is valid based on the current max and min.

  4. Contribution by Boundary

    Contribution By Boundary When To Use Use this when summing over all subarrays and each element contributes as the minimum or maximum over some range.

  5. Farthest Candidate Stack

    Farthest Candidate Stack When To Use Use this when you need the farthest valid index, not the nearest greater/smaller index.

  6. Greedy Remove Stack

    Greedy Remove Stack When To Use Use this when building a lexicographically smallest/largest subsequence while you are allowed to drop elements.

  7. 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.

  8. Exactly K via At Most

    Exactly K via At Most Template Use this when counting subarrays/substrings with exactly k of something.

  9. Fixed Size Window

    Fixed Size Window Template Use this when every candidate window must have exactly size k.

  10. Last Seen Jump Left

    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.