Problem: Contest Page | CodeChef
DIFFICULTY:
EASY.
PROBLEM:
Chef has a binary array in an unsorted manner. Cheffina challenges chef to find the transition point in the sorted (ascending) binary array. Here indexing is starting from 0.
Note: Transition point always exists.
Program:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--){
int n,x;
cin>>n;
int one=0;
for(int i=0;i<n;i++){
cin>>x;
if(x==1)one++;
}
cout<<n-one<<endl;
}
}