SPELLBOB PROBLEM

#include
#include<bits/stdc++.h>
using namespace std;
void bob()
{
char front[3],rear[3];
char bob[]=“bob”;
int count=0;
cin>>front>>rear;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
if(front[i]==bob[j] || rear[i]==bob[j])
count++;
}
}
if(count==3)
cout<<“yes”<<endl;
else
cout<<“no”<<endl;
}
int main()
{
int t;
cin>>t;
while(t–)
bob();
return 0;
}

Hello Adil,
Your code will give wrong answer for test case such as

1
bbb
bbb

Here there is no ‘o’, still count will increase because you are using or operator.
Try to solve this question by counting each ‘b’ and ‘o’ individually.
You can also go for all possible cases as there are only 8 case.

1 Like