DSA sheet · Sliding Window

Sliding Window DSA Notebook

My study notes from the Sliding Window playlist. Each page is written so that a beginner (or me, after forgetting everything) can read it once and understand when the window grows, when and why it shrinks, the Python code line by line, and a full dry run with the window drawn moving across the array.

The one idea behind every page Instead of checking every subarray from scratch (O(n²)), keep one window [left..right] and reuse its work: add the new item on the right, and remove items from the left only when the window breaks the rule.
Each item enters once and leaves once, so the whole scan is O(n). Two shapes: fixed size k (slide by one each step) and variable size (grow until invalid, then shrink).

Every page follows the same order:
① question in simple words → ② constraints → ③ intuition → ④ building the logic from examples → ⑤ approach steps → ⑥ code → ⑦ line by line → ⑧ dry run with the window drawn → ⑨ complexity & remember

Start here

Fixed-size window

Variable window: longest valid

Variable window: shortest valid

Counting windows

Kadane's Algorithm

Numbers follow the playlist order (videos 10 and 11 share page 10, so the pages are numbered 1–14; pages 15–16 are the Kadane videos, playlist #22–23). "Next →" at the top of each page follows that order.