2016. Reduction Operations to Make the Array Elements Equal
My accepted Python solution to LeetCode problem 2016, Reduction Operations to Make the Array Elements Equal, running in 108ms.
- Difficulty: Medium
- Python
- Runtime 108ms
- Memory 24.4MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 108ms, memory 24.4MB, accepted 2025-12-30.
class Solution:
def reductionOperations(self, nums: List[int]) -> int:
nums.sort()
n = len(nums)
result = 0
count = 0
for i in range(1, n):
if nums[i] != nums[i - 1]:
count += 1
result += count
return result