Please support me on Patreon: https://www.patreon.com/thesimpleengineer
https://twitter.com/thesimpengineer https://www.linkedin.com/in/schachte/
https://ryan-schachte.com
Don't forget to subscribe! Code:
https://gist.github.com/Schachte/87d7c0165a584f26b3ad7845f8010387
In this video, we'll begin our series of algorithmic mental models and cover the idea behind the sliding window technique. This technique allows us to reduce a typical n^2 algorithm to a linear time algorithm with minimal effort. This exploits linear time optimizations on data structures that deal with iteration and group sequential pieces of data together.
More resources:
https://medium.com/@zengruiwang/sliding-window-technique-360d840d5740
https://thesimpleengineer.com
https://stackoverflow.com/questions/8269916/what-is-sliding-window-algorithm-examples
*Timestamps*
00:00 Welcome
8:25 Maximum sum of contiguous subarray of size 3.
16:35 Question variants
24:50 Dynamic variant. Smallest subarray with given sum.
27:45 Smallest subarray code start
32:48 Smallest subarray solution
33:20 Longest substring with length k distinct characters