The Mirror of Galadriel
Link to the question : AMR12D
HINT :
If you go through th question and see the example, you will notice that all sub strings are palindrome only if the entire string is palindrome. So we just need to check whether the input string is palindrome.
SOURCE CODE :
#include<stdio.h>
#include<string.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char a[100],k,i;
scanf("%s",a);
k=strlen(a);
int f=0;
for(i=0;i<k/2;i++)
{
if(a[i]!=a[k-i-1])
{
f=1;
break;
}
}
if(f==0)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
#include<string.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char a[100],k,i;
scanf("%s",a);
k=strlen(a);
int f=0;
for(i=0;i<k/2;i++)
{
if(a[i]!=a[k-i-1])
{
f=1;
break;
}
}
if(f==0)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
No comments:
Post a Comment