function minWindow(s: string, t: string): string {
const need: Record<string, number> = {};
let miss = 0;
for (const ch of t) {
if (need[ch]) need[ch] += 1;
else {
need[ch] = 1;
miss++;
}
}
let left = 0;
let right = 0;
let start = 0;
let min = s.length + 1;
while (right < s.length) {
if (need[s[right]] != null) need[s[right]]--;
if (need[s[right]] === 0) miss--;
while (miss === 0) {
if (right - left + 1 < min) {
start = left;
min = right - left + 1;
}
if (need[s[left]] != null) need[s[left]]++;
if (need[s[left]] > 0) miss++;
left++;
}
right++;
}
return min === s.length + 1 ? "" : s.slice(start, start + min);
}