My issue
i tried every single test case in my mind but i did passed the last test case, could anyone share the last test case for this problem, i will really appreciate it.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t=1;
cin>>t;
while(t--)
{
string s1,s2;
cin>>s1>>s2;
int n=s1.length();
if(n<s2.length())
{
cout<<-1<<endl;
continue;
}
vector<int> v(n);
int j=s2.length()-1;
for(int i=n-1;i>=0;i--)
{
if(j==-1) break;
if(s1[i]==s2[j])
{
v[i]=1;
j--;
}
}
if(j!=-1)
{
cout<<-1<<endl;
continue;
}
int sum=0;
int count=1;
for(int k:v)
{
if(k==0)
{
sum+=count;
}
else{
count++;
}
}
cout<<sum<<endl;
}
return 0;
}
Problem Link: Transform String Practice Coding Problem