Jul 18, 2026
postorder merge instead of building the result, as we go down, we build it POST order as in after the rec step this is very similar to DP except since you are only dependent on children states you usually optimise globally and return NEEDED state problems maximum path sum on a binary tree f(u) → max...
Jul 18, 2026
Base Monotonic Deque When To Use Use this when you need the best max/min candidate among active indices. The deque stores indices.
Jul 18, 2026
Base Mono Stack When To Use Use this when each index needs the nearest greater/smaller element on one side.
Jul 18, 2026
DP Window Optimisation When To Use Use this when a DP transition asks for min or max over a moving valid range.
Jul 18, 2026
Fixed Window Extrema When To Use Use this when every query is over a fixed-size window and you need the max or min.
Jul 18, 2026
Prefix Sum Candidates When To Use Use this when candidates are prefix indices and the deque keeps the best prefix sums.
Jul 18, 2026
Variable Window Max Min When To Use Use this when a variable-size window is valid based on the current max and min.
Jul 18, 2026
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.
Jul 18, 2026
Farthest Candidate Stack When To Use Use this when you need the farthest valid index, not the nearest greater/smaller index.
Jul 18, 2026
Greedy Remove Stack When To Use Use this when building a lexicographically smallest/largest subsequence while you are allowed to drop elements.