You are given an integer array arr. Your goal is to strategically remove elements to reduce the array size by at least half, but here's the catch: when you choose to remove a number, all occurrences of that number must be removed from the array.
Your mission: Find the minimum number of distinct integers you need to remove to achieve this goal.
For example, if you have the array [3,3,3,3,5,5,5,2,2,7] with 10 elements, you need to remove at least 5 elements. The smart strategy would be to remove all 3's (removes 4 elements) and all 5's (removes 3 elements), giving you 7 total removals with just 2 distinct numbers chosen.
Think of it as: You're a data cleanup specialist trying to minimize the number of different deletion operations while maximizing impact!
Input & Output
Constraints
- 1 โค arr.length โค 105
- 1 โค arr[i] โค 105
- arr.length is always even