bool judge(int* s,int* t){
for(int i=0;i<200;i++){
if(s[i]<t[i]) return false;
}
return true;
}
char* minWindow(char* s, char* t) {
int ns=strlen(s),nt=strlen(t);
char* temp=(char*)malloc(sizeof(char));
temp[0]=0;
if(nt>ns) return temp;
int tn[200]={0};
int tt[200]={0};
for(int i=0;i<nt;i++) tt[t[i]-'A']++;
int head=0,tail=0,minhead=0,min=INT_MAX;
tn[s[head]-'A']++;
while(tail<ns){
printf("%d ",tail );
if(judge(tn,tt)){
if(tail-head+1 < min){
min=tail-head+1;
minhead=head;
}
tn[s[head++]-'A']--;
while(head<tail && tt[s[head]-'A'] ==0 ) head++;
}else{
tail++;
if(tail<ns) tn[s[tail]-'A']++;
}
}
if(min==INT_MAX) return temp;
char* array=(char*)malloc(sizeof(char)*(min+1));
for(int i=minhead;i<minhead+min;i++) array[i-minhead]=s[i];
array[min]=0;
return array;
}
标签:子串,200,覆盖,int,最小,76 From: https://www.cnblogs.com/llllmz/p/18083154