Minimum Window Substring
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 `""`. **Examples:** ```typescript minWindow("ADOBECODEBANC", "ABC") // "BANC" minWindow("a", "a") // "a" minWindow("a", "aa") // "" ```
Solve It in the BrowserPractice Explaining It Out Loud
Optimal Approach
- Time complexity: O(m + n)
- Space complexity: O(m + n)
Both left and right pointers traverse string s of length m at most once.
Follow-Up Questions Interviewers Ask About Minimum Window Substring
- Why use formed === required rather than comparing full frequency maps?
formed tracks how many unique characters have satisfied their required frequency, allowing O(1) validity checking.
Practice the full problem with execution, tests, and AI code review in the interactive lab — then rehearse explaining your solution in a live voice mock interview.