← Visualizers
Sliding Window — Variable LeetCode 76

Minimum Window Substring / visualized

Find the shortest window in s containing every character of t (with multiplicity). The trick that keeps it O(n): a formed / required counter tracks how many distinct characters are fully satisfied, so you never rescan the whole frequency map. Expand right until valid, then contract left as far as it'll go.

Execution

idle
Press Run to begin.
0 / 0
Speed

Java · running line

char needed by t in window contracting best window
O(|s| + |t|) time · O(|s| + |t|) space  ·  formed==required is the O(1) validity check that replaces re-comparing the whole map each step.