2
public int minSetSize(int[] arr) {5
int countIteration = 0;6
Map<Integer, Integer> hashMap = new HashMap<>();7
Queue<Map.Entry<Integer, Integer>> queue =8
new PriorityQueue<>((a, b) -> b.getValue() - a.getValue());10
for (int i = 0; i < size; i++) {11
if (hashMap.get(arr[i]) != null) hashMap.put(arr[i], hashMap.get(arr[i]) + 1);12
else hashMap.put(arr[i], 1);15
for (Map.Entry<Integer, Integer> entry : hashMap.entrySet()) {19
while (!queue.isEmpty()) {20
int totalOccurence = queue.poll().getValue();21
deletedSize += totalOccurence;23
if (deletedSize >= size / 2) return countIteration;25
return countIteration;