my code
#include<bits/stdc++.h>
using namespace std;
int main() {
int n ;
cin >> n;
string s1 , s2 , s3;
cin >> s1 >> s2;
string s = s1 + s1;
int count = 0;
for (int i = 0 ; s3 != s2 ; i++) {
// int a = s.find()
s3 = s.substr( i , s1.length() );
count++;
}
cout << count - 1;
return 0;
}
In this when I try to rotate the small sized string it is working fine but when I tried with some large length string it is showing error
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr: __pos (which is 227) > this->size() (which is 226)
I'm not understanding what is happening as with the string length of 20 or 30 it is working fine but when then string length is over the 110 it is showing this type of error.
Also this testcase is showing error
113 ndafmffmuuwjzqpquwjhuftohawpfegsjvnxwipwqlswvawogjuyiqtzsgpwgosegmuuhpzwchejuiitumyescxxyecnsatcbfpseqzowvdjyvchg zqpquwjhuftohawpfegsjvnxwipwqlswvawogjuyiqtzsgpwgosegmuuhpzwchejuiitumyescxxyecnsatcbfpseqzowvdjyvchgavqnonmkwgqp