My issue
can anyone please explain , why this code is wrong.
My code
#include <iostream>
using namespace std;
int main() {
int T;
string S;
cin >> T;
for(int i = 0; i < T; i++){
cin >> S;
int length = S.length();
int middle = length/2;
string first_half = S.substr(0,middle);
string second_half = S.substr(middle);
if(first_half+second_half == S || second_half+first_half == S || first_half == second_half )
{
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
return 0;
}
Problem Link: BROKENSTRING Problem - CodeChef