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 "".
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 "".
Example 1
Input: s = "ADOBECODEBANC", t = "ABC" Output: "BANC"
Example 2
Input: s = "a", t = "a" Output: "a"
Show hint
Use sliding window with two pointers. Expand right until all characters are found, then shrink left to minimize window while maintaining all characters.
Sign in to submit, save progress and mark problems as solved. You can still run your code.
Loading editor...
s =
"ADOBECODEBANC"
t =
"ABC"
Expected
"BANC"