LeetCode solutions

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

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.2MB, accepted 2025-12-30.

python
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

Source