Explanation
Minimum Window Substring is a Hard interview problem tagged [Hash Table, String, Sliding Window]. The winning approach is typically **Sliding Window**.
#76
Given two strings s and t of lengths m and n respectively, 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 testcases will be generated such that the answer is unique.
Example 1
Input: s = "ADOBECODEBANC", t = "ABC"
Output: "BANC"
The minimum window containing A, B, and C is BANC.
Example 2
Input: s = "a", t = "a"
Output: "a"
The whole string is the window.
Example 3
Input: s = "a", t = "aa"
Output: ""
Not enough a's in s.
Minimum Window Substring is a Hard interview problem tagged [Hash Table, String, Sliding Window]. The winning approach is typically **Sliding Window**.
Each index enters and leaves the window at most once → amortized O(n).
Grow a right edge to include new elements; shrink the left edge when the window violates a constraint. Track the best window.
Pattern-level skeleton only — not this problem’s exact answer. Adapt it to the statement.
Time: O(n log n) – O(n²)
Space: O(n)
Before coding, restate the problem, name the pattern (Sliding Window), and write the invariant or DP state in one sentence.
Got it?
Mark #76 Minimum Window Substring as understood when the pattern clicks.