We’re preparing your current view and syncing the latest data.
You are given an integer array arr and an integer k. Remove exactly k elements from the array. Return the least number of unique integers left in the array after removing k elements.
An array of integers arr and an integer k.
An integer representing the minimum number of unique integers remaining after removing k elements.
1 <= arr.length <= 10^5 0 <= k <= arr.length 1 <= arr[i] <= 10^9
Example 1
Input
arr = [5,5,4], k = 1
Output
1
Explanation
Remove one occurrence of 4 or 5. Removing 4 leaves the array [5,5], which has 1 unique integer.
Example 2
Input
arr = [4,3,1,1,3,3,2], k = 3
Output
2
Explanation
Removing three 1's or 2's and 1's reduces the unique integers to 2.