My all testcases except 2 testcases passed and I got wrong answer in these two test cases. Please help
Wrong answer in two test cases
Can you share me your code
#include
#include
#include
using namespace std;
int main()
{
string s1,s2;
getline(cin,s1);
getline(cin,s2);
int a[256]={0};
int b[256]={0};
if(s1.size()<s2.size())
{
cout<<“No string”<<endl;
return 0;
}
for(long long int i=0;i<s2.size();i++)
{
b[s2[i]]++;
}
long long int count=0,start=0,start_index=-1,minlength=INT_MAX;
for(long long int i=0;i<s1.size();i++)
{
a[s1[i]]++;
if(b[s1[i]]>0&&a[s1[i]]<=b[s1[i]])
{
count++;
}
if(count==s2.size())
{
while(a[s1[start]]>b[s1[start]]||b[s1[start]]==0)
{
if(a[s1[start]]>b[s1[start]])
{
a[s1[start]]--;
}
start++;
}
long long int len_window=i-start+1;
if(len_window<minlength)
{
minlength=len_window;
start_index=start;
}
}
}
if(start_index==-1)
cout<<"No string"<<endl;
else
cout<<s1.substr(start_index,minlength);
return 0;
}
Can you please put this code in the coding blocks ide and share it back to me
Yes, I open collaborate mode after putting code in ide.
Let me check it once
Please reply to my doubt as soon as possible.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.