1
class Solution {
2
public int reductionOperations(int[] nums) {
3
Map<Integer, Integer> valMap = new TreeMap<>(Collections.reverseOrder());
4

5
for (int i = 0; i < nums.length; i++) valMap.put(nums[i], valMap.getOrDefault(nums[i], 0) + 1);
6

7
int mapSize = valMap.size();
8
int opsCount = 0;
9
for (Map.Entry<Integer, Integer> entry : valMap.entrySet()) {
10
opsCount += entry.getValue() * (--mapSize);
11
}
12
return opsCount;
13
}
14
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0