#include
#include
#include
using namespace std;
int main()
{
unsigned int i,j;
int t;
cin>>t;
while(t–)
{
string str;
cin>>str;
char a[500],b[500];
if(str.length()%2==0)
{
for(i=0;i<((str.length())/2);i++)
{
a[i]=str.at(i);
b[i]=str.at(i+(str.length()/2));
}
}
else
{
for(i=0;i<((str.length()-1)/2);i++)
{
a[i]=str.at(i);
b[i]=str.at((i+(str.length()-1)/2)+1);
}
}
for(i=0;i<str.length()/2;i++)
{
for(j=i;j>0;j--)
{
if(a[j]>a[j-1])
{
a[j-1]=a[j]+a[j-1];
a[j]=a[j-1]-a[j];
a[j-1]=a[j-1]-a[j];
}
if(b[j]>b[j-1])
{
b[j-1]=b[j]+b[j-1];
b[j]=b[j-1]-b[j];
b[j-1]=b[j-1]-b[j];
}
}
}
int flag=0;
for(i=0;i<str.length()/2;i++)
{
if(a[i]!=b[i])
{
flag=1;
break;
}
else{continue;}
}
if(flag==0){cout<<"YES";}
else{cout<<"NO";}
}
return 0;
}
it was my code as an answer to the LAPINDROME problem in Easy problems’ section. I have checked it with numerous test cases and got the correct output always, still it is showing wrong answer.Can anyone tell me the reason?