How to correct my solution? : Change It - December Cookoff

Hi! I recently participated in the December Cookoff. I don’t want to make excuses but my rating went down from 2star to 1star because I wasted all my time on the first problem trying to figure out what was wrong in it. I think instead of becoming sad and wasting my time, I should use it as a great learning opportunity.

My Solution
So, this solution got the wrong answer. Basically I am iterating through the consecutive pairs in the array and checking if we can increment the counter (we increment the counter exactly when both the elements are NOT the most common element in the array). I tried several test cases on my own and it gave the correct answer on all. I even saw the solutions of random other people and their solutions are also similar to mine. So my question is: What is this solution missing? Edge Cases?

Any help would be appreciated.

Thank you.

Bro , i don’t get c++ but i think the question is just too easy you don’t need to do such complicated way of doing a problem.

the logic of the problem was just to subtract count of mode(list)(which returns the most occuring integer in the list) from len(list)

I don’t get your code. But what I have done is create an array of 100 elements. Initialize all of them to 0.iterate over to take input and when a value x is encountered update a[x]++ .after all this just print N-maxElementOfArray

Hi! you can directly find the maximum frequency of a number .
then the answer will be (n-(max frequency)).
because we can make all numbers equal by minimum interchanging that much of times.