i dont know which test case is failing
this is my solution of string window problem
#include<bits/stdc++.h>
using namespace std;
string stringWindow(string text,string pattern){
int n = text.length();
int m = pattern.length();
int startIndex = -1;
int start = 0, count = 0;
int hash_text[257] = {0};
int hash_pattern[257] = {0};
int minLength = INT_MAX;
for(int i = 0; i < m; i++){
hash_pattern[pattern[i]]++;
}
for(int j = 0; j < n; j++){
hash_text[text[j]]++;
if(hash_pattern[text[j]] != 0 && hash_text[text[j]] <= hash_pattern[text[j]]){
count++;
}
if(count == m){
while(hash_text[text[start]] > hash_pattern[text[start]] || hash_pattern[text[start]] == 0){
if(hash_text[text[start]] > hash_pattern[text[start]]){
hash_text[text[start]]--;
}
start++;
}
int currentLength = j - start + 1;
if(currentLength < minLength){
minLength = currentLength;
startIndex = start;
}
}
}
return text.substr(startIndex,minLength);
}
int main(){
string text,pattern;
getline(cin,text);
getline(cin,pattern);
cout << stringWindow(text,pattern) << endl;
return 0;
}