AlgoScope

Fixed-Size Window

AlgorithmbeginnerSliding Window

A window of size k. Add what enters, subtract what leaves, never re-add the middle.

Decision · step 2 of 7Sliding Window: Largest sum of 3 in a row
active 1-32011521334257617leftright

2 leaves and 1 enters, so the sum is 7. The best stays at 8.

Open in the player →or start at step 2

What you will see

The frame is always k wide; the running sum updates with two arrows.

How sliding window works →

Cost

BestO(n)
AverageO(n)
WorstO(n)
SpaceO(1)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.

Screen readers: Cells announce index, value and whether they are inside the window; each step announces the window bounds and the running value.

Reduced motion: The window frame snaps to its new bounds with a crossfade.

Before this

Leads to

Topics that need this one first.

Taught by the same lesson

Sliding Window covers these too, in the same run.