Majority Element

I have written this code in C++ which is a bit different from the explanations given in the lecture but the underlying logic is the same. I am still not able to pass test case 1 for some reason. I even went through the whole lecture again and rewrote the code line by line still the test case 1 isn’t being accepted. It is always giving “Wrong Answer”. Could you please tell me a possible test case for which my solution may not work properly?

#include
#include <bits/stdc++.h>
using namespace std;

void majority(vector v)
{
int element1 = 0;
int element2 = 0;
int count_1 = 0;
int count_2 = 0;
for(int i=0;i<v.size();i++)
{
if(v[i]==element1)
{
count_1++;
}
else if(v[i]==element2)
{
count_2++;
}
else if(count_1==0)
{
element1 = v[i];
count_1 = 1;
}
else if(count_2==0)
{
element2 = v[i];
count_2=1;
}
else
{
count_1–;
count_2–;
}
}
count_1=0;
count_2=0;
for(int i = 0; i < v.size(); i++)
{
if(v[i] == element1)
{
count_1++;
}
else if(v[i] == element2)
{
count_2++;
}
}
vector ans;
if(count_1>v.size()/3)
{
ans.push_back(element1);
}
if(count_2>v.size()/3)
{
ans.push_back(element2);
}
if(ans.size() == 0)
{
cout<<“No Majority Elements”;
}
else
{
sort(ans.begin(),ans.end());
for(int j = 0; j<ans.size();j++)
{
cout<<ans[j]<<" ";
}
}
cout<<endl;
}

int main() {
int n;
cin>>n;
vector v;
int num;
for(int i = 0; i<n; i++)
{
cin>>num;
v.push_back(num);
}
majority(v);
return 0;
}