Minimum Window Substring
Problem statement
Given strings s and t, find the shortest contiguous part of s that contains every character of t with its required multiplicity. Return that part of s. If no part qualifies, return an empty string.
For these test cases, a shortest qualifying window, when one exists, is unique. Treat uppercase and lowercase letters as different characters.
Function
minWindow(s: String, t: String) → StringExamples
Example 1
s = "ADOBECODEBANC"t = "ABC"return = "BANC"The final four characters contain each required letter; no shorter window does.
Example 2
s = "a"t = "a"return = "a"The only character supplies the target.
Example 3
s = "a"t = "aa"return = ""There is only one copy of a, so no valid window exists.
Constraints
1 ≤ s.length, t.length ≤ 10^5.- Both strings contain only uppercase and lowercase English letters.
- The total input fits in memory.