My issue
what shall be the test cases my code doesn’t work?
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while (t--) {
long long n,i, one = 0, zero = 0, ans = 0,min=0,max=0;
cin >> n;
string s;
cin>>s;
for ( i = 0; i < n; i++) {
if (s[i] == '1')
one++;
else
zero++;
}
if(one>zero){
min=zero;
max=one;
}
else
{
min=one;
max=zero;
}
if(min==0)
min=1;
for (i = min; i <= n;i++ ) {
if((i-min)%2==0||(i-max)%2==0)
ans++;
}
cout << ans << endl;
}
}
Problem Link: Convert string Practice Coding Problem