Nathan is a Researcher in English Literature. According to him string which when split in the middle, gives two halves having the same characters and the same frequency of each character is termed as Lapindrome.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{int arr1[26],arr2[26];
int t;
scanf("%d",&t);
char S[1000];int i=0;
while(i<t){
scanf("%s",S);
int l=strlen(S);
arr1[0]=0;arr2[0]=0;
for(int j=0;j<l;j++){
arr1[0]+=S[j]*(j<l/2);
if(l%2==0) arr2[0]+=S[j]*(j>=l/2);
else arr2[0]+=S[j]*(j>l/2);
}
if(arr1[0]==arr2[0])printf("YES\n");
else printf("NO\n");
i++;
}
return 0;
}
Comments
Post a Comment