AlgoScope

Minimum Window Substring

AlgorithmadvancedSliding Window

Expand until the window covers all required characters, then shrink while it still does.

Decision · step 2 of 25Substring Windows: Smallest window covering abc
window 0-0a0d1o2b3e4c5o6d7e8b9a10n11c12lr

r = 0, 'a' enters. It was still needed, so missing drops to 2.

Open in the player →or start at step 2

What you will see

A frequency table beside the string; the window shrinks the moment coverage is met.

How substring windows works →

Cost

BestO(n)
AverageO(n + m)
WorstO(n + m)
SpaceO(alphabet)

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.

Taught by the same lesson

Substring Windows covers these too, in the same run.