chef and feedback

#include
using namespace std;
int main()
{
int t,count,i=0;
char str[100005];
count=0;
cin>>t;
while(t–)
{

	cin>>str;
	while(str[i]!=NULL)
	{
		if((str[i]=='0' && str[i+1]=='1' && str[i+2]=='0') || (str[i]=='1' && str[i+1]=='0' && str[i+2]=='1'))
		 {
		 	count++;
		 }i++;
	}
     if(count!=0)
	 {
	 	cout<<"Good"<<endl;
	 	count=0;
	 }	
else cout<<"Bad"<<endl;
}

}

shows wrong answer

You forgot to initialize i to zero everytime :smiley:

Also it is a bad practice to write while(str[i]!=NULL). When you are on the last character, it will be some valid string character, s[i+1] will be ‘\0’ and s[i+2] will be some random value you cannot predict. It wont affect you in this case but is a bad practice in general especially in the case of something like linked list. The condition while(str[i+2]!=NULL) would have been more appropriate.

//