DSA problem
Minimum Window Substring
Given two strings s and t, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "".
The test cases are generated such that the answer is unique.
A substring is a contiguous, non-empty sequence of characters. The goal is to find the shortest contiguous segment of s that covers every required character of t with the correct multiplicity. The optimal approach uses a variable-size sliding window: expand the right edge until the window is valid, then shrink the left edge as far as possible while it stays valid, recording the smallest valid window seen.
Examples
s = "ADOBECODEBANC", t = "ABC""BANC"s = "a", t = "a""a"s = "a", t = "aa"""Constraints
- m == s.length
- n == t.length
- 1 <= m, n <= 10^5
- s and t consist of uppercase and lowercase English letters.
3 hints and a full solution walkthrough with step-by-step visualizations are available in the practice editor.