String window : clears only 2 testcases

My code is working for all custom test cases but only clearing 2 out of 10 and giving run-error on the rest id there something i missed ?

#include
#include<limits.h>
#include
using namespace std;
int main() {
string s;
string s1;
getline(cin,s);
getline(cin,s1);
string arr[s.length()%s1.length()];
int arr1[s.length()%s1.length()] = {0};
int p = 0;
for(int i = 0 ;i < s.length(); i++)
{
if(s[i] == s1[0])
{
p++;
arr1[p-1] = 1;
}
for(int j = 0 ; j < p ;j++)
{
if(arr1[j] == s1.length())
continue;
if(s1[arr1[j]] == s[i])
arr1[j]++;
arr[j] = arr[j]+ s[i];
}
}
int min = INT_MAX;
string minS = “”;
for(int i = 0 ; i< p ;i++)
{
if(arr1[i] == s1.length())
if(arr[i].length() < min)
{
min = arr[i].length();
minS = arr[i];
}
}
if(min != INT_MAX)
cout << minS;
else
cout << “No string”;
return 0;
}

Hi

share your link on IDE
and explain a little about your logic

hints for the question
First check if length of string is less than the length of given pattern, if yes then "no such window can exist ".
Store the occurrence of characters of given pattern in a hash_pat[].
Start matching the characters of pattern with the characters of string i.e. increment count if a character matches
Check if (count == length of pattern ) this means a window is found
If such window found, try to minimize it by removing extra characters from beginning of current window.
Update min_length
Print the minimum length window.

yeah so basically what i am doing is storing in the arr array every possible combination of substring containing the letters of the second string … in arr1 i am storing how many consecutive characters of second string were found
Now i am iterating character by character in the first string and then if the first the letter of the second string matches any in the first string then i am starting to concat it to the arr array and keeping count in the second array arr1 how many characters matched in second string with characters in the string if they match then i increment the counter of that string if the counter == length of second string i stop concating to the current string … in the end i iterate through the arr … to check min length string which should also consecutively have all characters of second string present for which i check in arr1 == s1.length and if it satisfies both conditions then there is a string else there is not

Please share your code on ide. and please contact me on 8750354215