Explanation:The function modifies nums to [1,2,_] and returns k = 2. The underscores represent elements beyond the returned k, which don't matter.
Example 2:
Input:nums = [0,0,1,1,1,2,2,3,3,4]
Output:5
Explanation:The function modifies nums to [0,1,2,3,4,_,_,_,_,_] and returns k = 5. The underscores represent elements beyond the returned k, which don't matter.
Example 3:
Input:nums = [1,1,1,1,1]
Output:1
Explanation:The function modifies nums to [1,_,_,_,_] and returns k = 1. Only one unique element (1) is present.
Example 4:
Input:nums = [1,2,3,4,5]
Output:5
Explanation:All elements are unique. The function modifies nums to [1,2,3,4,5] (no change) and returns k = 5.
Example 5:
Input:nums = [1]
Output:1
Explanation:The array has a single element, which is unique. The function returns k = 1.