gain traverse the array and find the actual counts .
for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == first ) count1 ++ ; else if ( arr [ i ] == second ) count2 ++ ; } if ( count1 > n / 3 ) { cout << first << " ▁ " ; flag = 1 ; } if ( count2 > n / 3 ) { cout << second << " ▁ " ; flag = 1 ; } if ( flag == 0 ) { cout << " No ▁ Majority ▁ Element " << endl ; } }