WA in LAPIN (yet again)

p;https://onlinegdb.com/SkmMt-ikI
q; LAPIN Problem - CodeChef
how can I make it correct??

instead of too much comparisions just maintain frequency array for each character for both halves of string then compare on the basis of frequency array it will be quite easy and clear.
you can checkout my code.

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
immortal_mark
AMAN KUMAR SINGH
IET LUCKNOW
JUST CODE FOR FUN
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#include<bits/stdc++.h>
#define fast_inou ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
using namespace std;
int main()
{
fast_inou

int t;
cin>>t;
while(t–)
{
int c[27],d[27],i,p=0;
for(i=0;i<=26;i++)
{
c[i]=0;
d[i]=0;
}
string s;
cin>>s;
int l=s.length();
if(l%2==0)
{
for(i=0;i<l/2;i++)
{
c[s[i]-97]=c[s[i]-97]+1;
}
for(i=l/2;i<l;i++)
{
d[s[i]-97]=d[s[i]-97]+1;
}
}
else
{
for(i=0;i<l/2;i++)
{
c[s[i]-97]=c[s[i]-97]+1;
}
for(i=(l+1)/2;i<l;i++)
{
d[s[i]-97]=d[s[i]-97]+1;
}
}
for(i=0;i<27;i++)
{
if(c[i]==d[i])
{
p=p+1;
}
}
if(p==27)
{
cout<<“YES”<<endl;
}
else
{
cout<<“NO”<<endl;
}
}
return 0;
}

c[s[i]-97]=c[s[i]-97]+1
int c[27],d[27],i,p=0;
why you are using 97 and 27 ?
please explain it

It’s for mapping characters to their appropriate indices.
Ex:if s[i]=‘a’ and c[0] =0
then the first statement that you have wrote will result in c[0]=1.As ‘a’ represent 97 in ASCII table.

these are ascii values of characters and there are total 26 character in our alphabet system thats why im taking array of 27.ascii table you can visit this site for ascii values.

The approach you used seems insignificant.
Your solution will only work with strings that have same sequences like aaabbaaabb
Use hashing instead
If you want to learn hashing view