My issue
I don’t understand what I am doing wrong here.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n;
cin>>n;
while(n--){
int m;
int zeroes=0,ones=0,k=0;
string s;
cin>>m>>s;
for(char c:s){
if(c=='1') ones+=1;
else if(c=='0') zeroes+=1;
}
if(m>1){
if(ones!=0 and zeroes!=0){
if(m%2==0){
k=(m-min(ones,zeroes))/2+1;
}
else{
k=m/2+2;
}}
else{
k=m/2+1;
}}
else{
k=0;
}
cout<<k<<endl;
}
}
Problem Link: Convert string Practice Coding Problem