Chapter Overview
Learn what we will be covering in this chapter.
“Animation is not the art of drawings that move but the art of movements that are drawn.”
In this chapter, we will learn about the sliding window technique and its different application programs.
Whenever we want to perform an exhaustive search on some smaller subset region sequentially, we can use the sliding windows technique.
The window can be either fixed-sized or dynamic-sized. In this technique, we slide a window across array elements or any arbitrary buffer of data to perform the desired operation.
This technique helps us write efficient code compared to naive approach techniques like brute-force search.
For instance, using the sliding window technique, finding the maximum sum of elements in an array or searching for
The different applications of this technique include:
- Problems that require contiguous or sequential iteration on strings or integer arrays and linked lists.
- Problems that have some criteria of comparison or involve some operation. For example, we can find the longest substring with a maximum of k distinct characters or a minimum or maximum sum subarray. We can even check the presence of certain characters in a word using this technique.