Sliding Window
The sliding window technique eases the task of finding optimal chunks of contiguous data that meet a certain condition:
Longest subarray that …
Shortest substring containing …
Etc
You can think of it as another variation of the two pointer technique, where pointers are updated separately based on a certain condition. Below is the basic recipe for this type of problems, in pseudocode:
Last updated