You are given an integer array arr. Choose a set of integers and remove every occurrence of them from the array. Return the minimum size of such a set so that at least half of the array is removed.
You are given an integer array arr. Choose a set of integers and remove every occurrence of them from the array. Return the minimum size of such a set so that at least half of the array is removed.
Example 1:
Input: {"arr":[3,3,3,3,5,5,5,2,2,7]}
Output: 2
Constraints:
2≤arr.length≤105
arr.length is even
1≤arr[i]≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"arr":[3,3,3,3,5,5,5,2,2,7]}
Remove whole values until at least 5 of the 10 elements are gone, using as few distinct values as possible.