Back to course home
0% completed
Vote For New Content
Solution: Least Number of Unique Integers after K Removals
Problem Statement
Given an array of integers arr
and an integer k
, return the least number of unique integers remaining after removing exactly k
elements from the array.
Examples
Example 1
- Input:
arr = [5, 5, 4, 3, 2, 3, 2, 3, 3, 2]
,k = 6
- Expected Output:
1
- Justification: After removing
4
, all5
, and three instances of2
, the updated array will be[3, 3, 3, 3]
. It will have only 1 unique element.
Example 2
- Input:
arr = [7, 7, 7, 8, 8, 9]
,k = 2
- Expected Output:
2
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page