Count Distinct Values
EasyArrayHash TableMath
Description
Given an array of integers nums, return the number of distinct values it contains.
Examples
Input:
nums = [1,1,2,3,3]Output:
3Explanation:
The list holds 3 different values once duplicates are removed.
Input:
nums = [5,5,5]Output:
1Explanation:
The list holds 1 different values once duplicates are removed.
Input:
nums = [7,8,9]Output:
3Explanation:
The list holds 3 different values once duplicates are removed.
Constraints
- •
1 ≤ nums.length ≤ 10⁴ - •
-10⁹ ≤ nums[i] ≤ 10⁹