class Solution { public: /** * * @param S string字符串 * @param T string字符串 * @return string字符串 */ map<char,int> mp1,mp2; bool judge(){ for(auto [a,b] : mp2){ if(mp1[a]<b) return false; } return true; } string minWindow(string S, string T) { // write code here int i,j,num=INT_MAX; string res; for(i=0;i<T.size();i++){ mp2[T[i]]++; } i=0,j=0; while(j<S.size()){ mp1[S[j]]++; while(judge()){ if(j-i+1<num){ num=j-i+1; res=S.substr(i,num); } mp1[S[i]]--; i++; } j++; } return res; } };