Maximum OR Minimum Solution || Codechef Starters - 37

        

Maximum OR Minimum Solution 

Codechef Starters - 37
Problem Code : MAXORMIN

Solution :

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll t = 1;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll a[n];
        ll one = 0, zero = 0;
        for (ll i = 0; i < n; i++)
        {
            cin >> a[i];
            if (a[i])
            {
                one++;
            }
            else
            {
                zero++;
            }
        }
        if (one >= zero)
        {
            cout << "1\n";
        }
        else
        {
            cout << "0\n";
        }
    }
}

Comments