$ cat ./coding/1338-reduce-array-size-to-the-half.md
[Coding]
1338. Reduce Array Size to The Half
────────────────────────────────────────────────────────────
1338. Reduce Array Size to The Half
class Solution:
def minSetSize(self, arr: List[int]) -> int:
counter = Counter(arr)
heap = []
for k, v in counter.items():
heapq.heappush(heap, (-v, k))
acc = 0
count = 0
total = len(arr)
while acc < total // 2 and heap:
v, k = heapq.heappop(heap)
acc -= v
count += 1
return count
--tags#Greedy#Heap#Hash Table
$ ls ./coding/ | grep -v 1338-reduce-array-size-to-the-half