int resl,resr;
string res="";
int mi = 0x3f3f3f3f;
unordered_map<char, int>ss;
unordered_map<char, int>tt;
set<char>fl;
class Solution {
public:
string minWindow(string S, string T) {
for (auto x : T)tt[x]++;
int l = 0, r = 0;
while(r<S.length())
{
bool flag=false;
char t=S[r];
if(tt.count(t)==0)
{
r++;
continue;
}
ss[t]++;
if(ss[t]==tt[t])fl.insert(t);
if(fl.size()==tt.size())flag=true;
while(flag)
{
t=S[l];
if(tt.count(t)==0)
{
l++;
continue;
}
ss[t]--;
if(ss[t]<tt[t])fl.erase(t),flag=false;
if(mi>r-l+1)mi=r-l+1,resl=l,resr=r;
l++;
}
r++;
}
if(mi==0x3f3f3f3f)return "";
for(;resl<=resr;resl++)res+=S[resl];
return res;
}
};