- tags: Sliding Window
- source: Moore, Jordan. “An Introduction to Sliding Window Algorithms.” Medium, July 26, 2020. https://levelup.gitconnected.com/an-introduction-to-sliding-window-algorithms-5533c4fe1cc7.
Efficientive algorithm:
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. – Antoine de Saint-Exupéry
The following return values can use a sliding window:
- Minimum value
- Maximum value
- Longest value
- Shortest value
- K-sized value
And contiguous is one of the biggest clues.
Common data structures are strings, arrays and even linked lists.
Framework:
- Slide right window to move forward
- Slide left window to meet the requirements.
- Compare to result.