Bootcamp
Search…
📅
Course Schedule
0: Language and Tooling Teaching Guide
1: Frontend Basics Teaching Guide
2: Backend Basics Teaching Guide
3: Backend Applications Teaching Guide
4: Backend Structure Teaching Guide
5: Full-Stack Applications Teaching Guide
6: Frontend Infrastructure Teaching Guide
7: React Teaching Guide
8: Advanced React Teaching Guide
9: Advanced Topics Teaching Guide
🧮
Algorithms Teaching Guide
💼
Interview Prep Teaching Guide
☺
User Experience Teaching Guide
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

Last modified 2mo ago