Sliding window technique is primarily used to solve problems where we want to find the longest contiguous array satisfying a constraint.

When does it make sense?

The constraint is calculated by a function . The sliding window technique makes sense when calculating with addition of or removal of is easy knowing the value of .