Loading...
You are given two strings s and t. Return the shortest contiguous substring (window) of s that contains every character of t, including duplicates: if t has a character twice, the window must contain it at least twice. Characters are case-sensitive.
If no such window exists, return the empty string "". If several windows tie for the minimum length, return the one that starts earliest in s. This tie-break makes the answer unique.
Input: s = "ADOBECODEBANC", t = "ABC"
Output: "BANC"
Explanation: "BANC" is the shortest window containing 'A', 'B' and 'C'.
Input: s = "a", t = "a"
Output: "a"
Input: s = "a", t = "aa"
Output: ""
Explanation: t needs two 'a's but s contains only one.
m == s.length, n == t.lengths and t consist of uppercase and lowercase English letters.Click "Run" to test with sample cases or "Submit" to run all tests.