Least Number of Unique Integers after K Removals LeetCode solution in Python
1from heapq import heappop, heapify234class Solution:56def findLeastNumOfUniqueInts(self, arr: List[int], k: int) -> int:78counter = collections.Counter(arr)910min_heap = [(count, num) for num, count in counter.items()]1112heapify(min_heap)1314while k > 0:1516count, num = min_heap[0]1718if count > k:1920break2122heappop(min_heap)2324k -= count2526return len(min_heap)