Given a vector of integers nums, return how many different values it has.
A value that appears several times counts only once.
Example 1:
Input: nums = [4, 7, 4, 1, 7] Output: 3 Explanation: The different values are 4, 7 and 1. The second 4 and the second 7 are repeats, so they don't count again.
Example 2:
Input: nums = [5, 5, 5] Output: 1 Explanation: Every number is 5, so there is only one different value.
Example 3:
Input: nums = [-2, 0, 3, 8] Output: 4 Explanation: No value repeats, so every number counts.
Constraints:
numshas at least one number.- Every number is between -109 and 109.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
