When should this come to mind?
Maintain a contiguous range, reusing information as its boundaries move.
Longest or shortest substringContiguous subarrayFixed-size KFrequency constraints
What makes it work
Both boundaries should advance monotonically; updates must be cheaper than rebuilding the window.
When to choose something else
A shrinking rule must be valid. For example, sum-based windows with negative numbers may not be monotonic.