Find the minimum number of operations needed to make all array elements distinct, using the operation allowed by the problem.
You are given an integer array. In one operation, you may modify the array according to the problem's allowed rule so that duplicates can eventually be removed. Your goal is to determine the minimum number of operations required so that every value in the array becomes distinct.
Think in terms of how many repeated elements must be resolved and how the operation affects the array globally or locally. Return the smallest number of operations needed to make the array contain no duplicate values.
nums.Note: This is a practice-oriented rephrasing; the implementation details should follow the platform's original operation rule.
Example 1
Input
nums = [1,2,3,4]
Output
0
Explanation
All elements are already distinct, so no operations are needed.
Example 2
Input
nums = [1,2,2,3,3,3]
Output
2
Explanation
The repeated values can be resolved in the minimum number of allowed operations, leaving all elements distinct.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.