PRPALN November Challange . Can anyone give failing test case for this code?

#include <stdio.h>
#include <string.h>

int main( )
{
    
    long long T, i, l, count, x, y;
    char s[1000000];
    
    scanf("%lld", &T);
    for(i = 1 ; i<=T; i++)
    {
        scanf("%s", s);
        l = strlen(s);
        
        x = 0;
        y = l - 1;
        count = 0;
        if(l == 1 || l ==0 )
        {
            printf("NO\n");
            continue;
        }
        while(x < y)
        {
            if(s[x] != s[y])
            {
                count = count + 1;
                if(s[x] == s[y-1])
                {
                    y = y -1;
                }else if(s[y] == s[x+1])
                {
                    x = x + 1;
                }
                else{
                    count = count + 1;
                    break;
                }
            }
            else
            {
                x++;
                y--;
            }
        }
        if(l%2 == 1)
        {
            if( count == 1 || count == 0)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else
        {
            if(count == 1 || count == 0)
            {
                printf("YES\n");
            }
            else
            {
                printf("NO\n");
            }
        }
    }
    return(0);
}

Your program fails for this case.

ahadadah

We can form a palindrome by deleting first character β€˜a’, so answer is β€˜YES’ … Your code outputs β€˜NO’.

1 Like

Thanks a lot !