My issue
Getting Runtime error , not sure why
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
string s;
cin>>s;
string s1= "101";
string s2 = "010";
bool flag = false;
for(int i= 0 ; i<s.size()-2 ; i++){
if(s.substr(i,3) == s1 || s.substr(i,3)== s2){
//cout<<"Good"<<endl;
flag=true;
break;
}
// else{
// flag =false;
// }
}
if(flag){
cout<<"Good"<<endl;
}
else{
cout<<"Bad"<<endl;
}
}
return 0;
}
Learning course: Level up from 1* to 2*
Problem Link: CodeChef: Practical coding for everyone