Find Majority Elements

Problem : https://hack.codingblocks.com/app/contests/1499/1509/problem

My Solution : https://ide.codingblocks.com/s/219441

Why i am getting wrong answer for testcase 0.

hi @vaishnavtannu, the problem is with your last else statement, the else statement will be provoked whenever if(count2 > n/3) is false, instead you want to call the statement inside else when both the above if statements returns false ,
so at line 74 change

else cout << “No Majority Elements” << endl;

to

if(count1<=(n/3)&&count2<=(n/3)) cout << “No Majority Elements” << endl;

In case of any doubt feel free to ask :slight_smile:
if you got the answer then mark your doubt as resolved