Https://hack.codingblocks.com/app/contests/1499

https://hack.codingblocks.com/app/contests/1499

In the very first problem of practice series for Bigwigs, FIND MAJORITY ELEMENT, one test case is showing the wrong answer for my code.

#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool check(ll arr[] , ll size, ll a){
ll c=0;
for(ll i=0;i<size ; i++)
if(arr[i]==a)
c++;
return c> (size/3);
}
void fun(ll arr[], ll size){
ll count1=0 ,count2=0 , first= INT_MAX , second=INT_MAX;
for(ll i=0 ;i<size;i++){
if(first==arr[i]){
count1++;
}else{
if(second==arr[i]){
count2++;
}else{
if(count1==0){
first=arr[i];
}else{
if(count2==0){
second=arr[i];
}else{
count1–;
count2–;
}
}
}
}
}
if(first>second)
swap(first , second);
bool f=check(arr , size , first);
bool s=check(arr , size , second);
if(f){
cout<<first<<" ";
}
if(s){
cout<<second;
}
if(!(f || s)){
cout<<“No Majority Elements”;

}

}

int main() {
ll n;
cin>>n;

ll arr[n];
for(ll i=0 ; i<n ; i++)
    cin>>arr[i];
fun(arr,n);
return 0;

}

i can’t see what the problem is. Please help.