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
- 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 11ms, memory 17.5MB, accepted 2025-12-30.
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