# WA in "Lapindromes" (LAPIN)

#include
#include<string.h>
using namespace std;

int main() {
int x;
cin>>x;
while(x>0)
{
string s;
cin>>s;
string s1,s2;
int t=s.length();
if(t%2==0)
{
int i=0;
for(;i<=(t/2)-1;i++)
s1+=s[i];
for(i=t/2;i<t;i++)
s2+=s[i];
}
else
{
int i=0;
for(;i<=(t/2)-1;i++)
s1+=s[i];
for(i=(t/2)+1;i<t;i++)
s2+=s[i];
}
int no=0;
if(t<=2)
no=1;
else
{
int count1=0;
int count2=0;
for(int i=0;i<s1.length();i++)
{
for(int j=0;j<s1.length();j++)
{
if(s1[i]==s1[j])
count1++;

``````           }

for(int j=0;j<s2.length();j++)
{
if(s1[i]==s2[j])
count2++;

}

if(count1!=count2)
no=1;
}
if(no==1)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
}
x--;
}
return 0;
``````

}

This code is correct but showing wrong ans while submiting

@raj_2020code Format your code first as the forum software has messed it up. Refer to the following guide by @ssjgz :

1 Like

Simply keep frequency of each character of left and right side. Make an array of size 26 and update it for each character found in left and right side.
You can see this CodeChef: Practical coding for everyone

Thanks a lot

ok thank you

as you are adding both half sides and checking weather it’s sum is equal or not.
But this is wrong approch because for eg try : ‘decf’ as input in your code will O/P “YES”
but the string ‘decf’ is not lapindrome.

This is because Ascii values of d & e are 100 & 101 : sum is = 201.
and Ascii values of c & f are 99 & 102 : sum is = 201.