#include<stdio.h>
int main()
{int a,i,j,k=0,l=0;
char ch[1000],*p;
scanf("%d",&a);
while(a--)
{scanf("%s",ch);
p=ch;
while(*p!='\0')
{k++;
p++;
}
for(i=0;i=k/2-1;i++)
for(j=k-1;j>k/2-1;j--)
{if(ch[i]==ch[j])
l++;
}
if(l==k/2)
printf("YES\n");
else printf("NO\n");
}
return 0;
}
Asked by: Avinash_Kumar on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.
your code's going into an infinite loop due to the condition in this loop which always remains true,
for(i=0;i=k/2-1;i++)
Your logic isn't correct either. I think you misunderstood the question. The question doesn't ask you to find if a given string is palindrome or not but whether two halves of the string have same characters and same frequency of each characters.
Hint : use hashing.
And from next time use the insert code snippet option to paste the code..makes it easier to read code. :)