#include<stdio.h>
#include<string.h>
int main()
{
int t,a,i,j,c;
char str1[1001],str2[501],str3[501],search;
scanf("%d",&t);
while(t--)
{
scanf("%s",str1);
a=strlen(str1);
for (i = 0; i <a/2; i++)
{
str2[i]=str1[i];
}
if(a%2!=0)
{
j=0;
for (i = a-1; i >a/2 ; i--)
{
str3[j]=str1[i];
j++;
}
}
else
{
j=0;
for (i = a-1; i >=a/2 ; i--)
{
str3[j]=str1[i];
j++;
}
}
// printf("%s %s\n",str2,str3);
for (i = 0; i < strlen(str2); i++)
{
search=str2[i];
// printf("%c\n",search);
for (c = 0; c < strlen(str3); c++)
{
// printf("%c\n",str3[c]);
if (str3[c] == search)
{
str3[c]='0';
// printf("\t%c\n",str3[c]);
break;
}
}
}
for (i = 0; i < strlen(str3); i++)
{
if(str3[i]!='0')
{
printf("NO\n");
break;
}
}
if (i==strlen(str3))
{
printf("YES\n");
}
}
}
Sorry I couldn’t get that
TLE is Time Limit Exceeded and WA is Wrong Answer. Which of these do you see when you run your code?
WA
Found the problem in your code. You were not clearing up str2 and str3 before making changes to them. This is the link to the working code : https://ideone.com/SbQrg1
Okayy thank you very much
Can I improve this more?