Skip to content

Commit a4321a8

Browse files
committed
Runtime: 717 ms (Top 99.99%) | Memory: 24.60 MB (Top 36.15%)
1 parent 336105f commit a4321a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Runtime: 717 ms (Top 99.99%) | Memory: 24.60 MB (Top 36.15%)
2+
13
class Solution:
24
def reductionOperations(self, nums: List[int]) -> int:
3-
return sum(accumulate(c for _,c in sorted(Counter(nums).items(), reverse=True)[:-1]))
5+
ans = val = 0
6+
nums.sort()
7+
for i in range(1, len(nums)):
8+
if nums[i-1] < nums[i]: val += 1
9+
ans += val
10+
return ans

0 commit comments

Comments
 (0)