Unnecessary wrong answer given on STRADJ starters div 2

Respected sir
I checked the video solution of the question. My approach was almost same to the answer given . I am not able to understand why my answer failed unnecessarily. Kindly clarify
Question : String Game(STRADJ)

Alice and Bob are playing a game on a binary string SS of length NN.

Alice and Bob alternate turns, with Alice going first. On their turn, the current player must choose any index 1≤i<|S|1≤i<|S| such that Si≠Si+1Si≠Si+1 and erase either SiSi or Si+1Si+1 from the string. This reduces the length of SS by one, and the remaining parts of SS are concatenated in the same order.

The player who is unable to make a move loses.

Determine the winner if both players play optimally.
It will be helpful if you can tell me why my code failed and on what test cases.
Contest starters 17 div 2
my solution in C++:
#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int n;
cin>>n;
string s;
cin>>s;
int count=0;
for(int i=0;i<n-1;i++){
if(s[i]!=s[i+1]){
i++;
count++;
}
}
if(count==0) cout<<“BOB”<<endl;
else if(count==1) cout<<“ALICE”<<endl;
else{
if(n%2==0){
cout<<“BOB”<<endl;
}
else if(n%2==1){
cout<<“ALICE”<<endl;
}
}

}
return 0;

}

Try the following testcase:

1
4
0011

Here Bob wins. Because no matter if Alice removes 0 or 1 on her turn, Bob can remove the same digit and then Alice has no moves left.

1 Like

Thank you
Got my mistake!
So early reply appreciated!