please someone tell me why my program is not workinh for all inputs.I got only 35 points in this program.I have tested this for all test cases that i can think of.

#include<stdio.h>
char a[100001];
int main()
{
int k;
long l,c,i,t;
scanf("%ld",&t);
while(t–)
{
scanf("%s",a);
l=0;
while(a[l]!=0)
++l;

		    k=0;
		    --l;
			c=l/2,i=0;
			while(c--)
			{
				
				if(k>1)
				{
				k=4;
				printf("NO\n");	
				break;
			    }
				if(a[i]==a[l]);
				else
				{
					if(i+1==l)
					{
						if(k==0);
						else
						{
							if(a[i]==a[l]);
							else
							k++;
						}
					}
					else if(a[i]==a[l-1])
					{
					++k;
					--l;
				    }
					else if(a[i+1]==a[l])
					{
					++k;
					++i;
				    }
					else
					{   
					    k=4;
						printf("NO\n");
						break;
					}
				}
				++i,--l;
			}
			if(k<=1)
			printf("YES\n");
			else if(k==2)
			printf("NO\n");
	}
	return 0;
}

Your code fails for this input

ahadadah

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

2 Likes

Thanks a lot