Back to problems Solve on LeetCode →

Minimum Window Substring

LeetCode 76 • Hard • Sliding Window

Find the minimum window in s that contains all characters from t.
Input: s = "ADOBECODEBANC", t = "ABC"  →  Output: "BANC"

TimeO(n+m)s + t
SpaceO(m)need + have maps
Window: Have: Best:
Window
Right (expand)
Shrink
Target chars
Window
Have
Best
Ready
Press Play. Expand right until window has all chars from t. Then shrink from left while valid. Track minimum window.