Minimum Drops to Equal

easypy_datastructures

Implement get_min_to_drop(seq).

Return the minimum number of elements to remove so that all remaining elements are equal. That equals len(seq) minus the count of the most frequent element (an empty sequence needs 0). For example get_min_to_drop([1, 2, 3, 1]) == 2 (drop the 2 and the 3, keep the two 1s).

Your solution

Edit get_min_to_drop and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

Count occurrences of each value; the answer is len(seq) minus the largest count.