Minimum Window Substring
Problem statement
Given strings s and t, return the shortest contiguous substring of s that contains every character of t, including repeated characters with their required multiplicities.
If no such substring exists, return the empty string. If several valid windows have the same minimum length, return the one that starts earliest in s.
Function
minWindow(s: String, t: String) → StringExamples
Example 1
s = "ADOBECODEBANC"t = "ABC"return = "BANC"BANC is the shortest window containing A, B, and C.
Example 2
s = "a"t = "aa"return = ""The source string does not contain two copies of a.
Example 3
s = "abdcab"t = "ab"return = "ab"Two length-two windows qualify, so the earlier one is returned.
Constraints
1 <= s.length, t.length <= 10^5.sandtcontain ASCII letters and digits.