Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int eve = 0, odd = 0;
int x;
while(n--){
cin>>x;
if(x % 2 == 0){
eve++;
}
else{
odd++;
}
}
cout<<min(odd, eve)<<endl;
}
}
Copy The Code &
Try With Live Editor
Input
2
5
2 4 3 6 8
6
3 5 9 7 1 3
5
2 4 3 6 8
6
3 5 9 7 1 3
Output
1
0
0
Demonstration
Codeforcess Solution 1691-A A. Beat The Odds ,C++, Java, Js and Python ,1691-A,Codeforcess Solution