https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/shreya-and-non-palindrome/submissions/
#include<stdio.h>
#include<string.h>
int main()
{
char str[1000000];
scanf(" %s", str);
int l = strlen(str) - 1, j, flag = 0,i;
for( i= l; i > 0; i--)
{
if(str[i] != str[0])
{
flag = 1;
break;
}
}
if(flag == 0)
printf("0");
else
{
for(j = 0; j <= i/2; j++)
if(str[j] != str[i-j])
{
printf("%d", i+1);
return 0;
}
}
}
No comments:
Post a Comment