Given strings s and t, return the shortest contiguous substring of s that contains every character from t with at least the same multiplicity. If no such substring exists, return the empty string. If several windows have the same minimum length, returning any one of them is acceptable — the supplied tests use unique answers.
Input / output
s: string, t: string"" if impossibleExamples
s = "ADOBECODEBANC", t = "ABC" returns "BANC".s = "a", t = "a" returns "a".s = "a", t = "aa" returns "" because s does not contain two a characters.Constraints
1 <= t.length <= s.length <= 10^5 for the canonical problems and t may contain uppercase letters, lowercase letters, and digitsTarget complexity
O(|s| + |t|) time and O(|alphabet|) extra space.Hints
t needs before you scan s.Follow-up
How would you adapt the technique if the requirement were "cover all characters from t in order" instead of with arbitrary order?