Output is correct but getting wrong answer during submission.

http://discuss.codechef.com/problems/ERROR

#include<stdio.h>
#include<string.h>
int main()
{
int i,t;
scanf(“%d”,&t);
for(i=1;i<=t;i++)
{
int len,j,k,l,flag=0,count1=0,count2=0,count3=0;;
char num1[100001];
char num2[3];
char sample1[3]={‘1’, ‘0’, ‘1’};
char sample2[3]={‘0’, ‘1’, ‘0’};
scanf(“%s”, num1);
len=strlen(num1);
for(j=0;j<len-2;j++)
{

		for(k=j;k<=j+2;k++)
		{
			num2[count1]=num1[k];
			count1++;
		}
		for(l=0;l<3;l++)
		{
			if(num2[l]==sample1[l])
			count2+=1;
		}
		for(l=0;l<3;l++)
		{
			if(num2[l]==sample2[l])
			count3+=1;
		}
		if(count2==3)
		{
			flag=1;
			break;
		}
		else if(count2==3)
		{
			flag=2;
			break;
		}
		count1=0,count2=0,count3=0;
	}
	if(flag==1 || flag==2)
	printf("GOOD");
	else
	printf("BAD");
	printf("\n");
}

return 0;
}

The else if statement in your code should have been:

else if(count3==3)

You are not comparing count3 due to which the strings having the substring “010” and not having the substring “101” are being treated as Bad strings and you are getting wrong answer during submission.

thanks a lot .

@its_sk_91 If your doubt has been resolved, please accept the solution by clicking on the tick mark beside the answer, otherwise, it leaves the question unaccepted. You can also upvote the answer by clicking on the thumbs up symbol.