1481. Least Number of Unique Integers after K Removals

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1481

class Solution:
    def findLeastNumOfUniqueInts(self, arr: List[int], k: int) -> int:
        cnt = Counter(arr)
        for i, v in enumerate(sorted(cnt.values())):
            k -= v
            if k < 0:
                return len(cnt) - i
        return 0