3998. Minimum Operations to Equalize Array
My accepted Python solution to LeetCode problem 3998, Minimum Operations to Equalize Array, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.2MB
- 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 0ms, memory 17.2MB, accepted 2025-12-30.
class Solution:
def minOperations(self, nums: List[int]) -> int:
# If all elements are equal, return 0
if len(set(nums)) == 1:
return 0
# Otherwise, one operation on the whole array makes all elements equal to AND of all
return 1