My issue
Can this problem be solved without the use of substring function?
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
return 0;
}
Problem Link: RECNDSTR Problem - CodeChef
Can this problem be solved without the use of substring function?
#include <iostream>
using namespace std;
int main() {
// your code goes here
return 0;
}
Problem Link: RECNDSTR Problem - CodeChef
@adrishratul
Here u go , solution without using substr .
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
if(s.size()<=2)
cout<<"YES";
else
{
string l,r;
for(int i=1;i<s.size();i++)
{
l+=s[i];
}
l+=s[0];
r+=s[s.size()-1];
for(int i=0;i<s.size()-1;i++)
{
r+=s[i];
}
if(l==r)
cout<<"YES";
else
cout<<"NO";
}
cout<<endl;
}
return 0;
}
but it is saying that l(s) = s ans r(s) = s
then how it is correct
as
eg:
s=abab
l(s)=baba != s (abab)
r(s)=baba != s (abab)