arr.count to store the occurrences of each number.count for each number.count array in descending order.removed to track the number of elements removed and setSize to track the size of the set.count array, adding the count to removed and incrementing setSize until removed is at least half the size of the original array.setSize as the result.