#3779
Minimum Number of Operations to Have Distinct Elements
medium · 42.1% accepted · 44 likes · top 23%
Description
You are given an integer array nums.
In one operation, you remove the first three elements of the current array. If there are fewer than three elements remaining, all remaining elements are removed.
Repeat this operation until the array is empty or contains no duplicate values.
Return an integer denoting the number of operations required.
Solution