Bootcamp
Search…
A.7: Sliding Windows
sliding windows

Introduction

Sliding window algorithms typically allow us to iterate through an array or string in linear time, sweeping over and analysing "windows" or subarrays of varying sizes by storing a start and end index of the current "window". We update the start and end indexes as we iterate through the array. See this explanation for an intro to sliding window algorithms. Use incognito mode to read the full article.

Exercises

Pre-Class

  1. 1.
    1. 1.
      Hint: Would nested loops be helpful, an outer loop that determines the length of the subarray, and an inner loop that sums all subarrays of a given length?
    2. 2.
      Rocket Academy solution code: https://pastebin.com/apxLUSQh​
  2. 2.
    1. 1.
      Hint: What determines the start and end of the sliding window?
    2. 2.
      Rocket Academy solution code: https://pastebin.com/WFGdNszB​
    3. 3.
      Rocket Academy solution video: https://youtu.be/Kynk1Tny3yQ?t=3939​

Part 1

More Comfortable

Copy link
On this page
Introduction
Exercises
Pre-Class
Part 1
More Comfortable