My issue
how is value term evaluated…i think o am not getting the question properly due to the term value
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int sumzero=0;
int sumone=0;
for(int i=0;i<n;i++)
{
if(s[i]=='1')
sumone+=i;
else
sumzero+=i;
}
if(abs(sumzero-sumone)<=n-1)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
}
Problem Link: Fair Distribution Practice Coding Problem - CodeChef