LeetCode solutions

3656. Minimum Number of Operations to Make Elements in Array Distinct

My accepted Python solution to LeetCode problem 3656, Minimum Number of Operations to Make Elements in Array Distinct, running in 11ms.

  • Difficulty: Easy
  • Python
  • Runtime 11ms
  • Memory 17.5MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 11ms, memory 17.5MB, accepted 2025-12-30.

python
class Solution:
    def minimumOperations(self, nums: List[int]) -> int:
        ops = 0
        while len(nums) > 0 and len(nums) != len(set(nums)):
            nums = nums[3:]  # Remove first 3 elements
            ops += 1
        return ops

Source