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:3
Explanation:

The list holds 3 different values once duplicates are removed.

Input:nums = [5,5,5]
Output:1
Explanation:

The list holds 1 different values once duplicates are removed.

Input:nums = [7,8,9]
Output:3
Explanation:

The list holds 3 different values once duplicates are removed.

Constraints

  • 1 ≤ nums.length ≤ 10⁴
  • -10⁹ ≤ nums[i] ≤ 10⁹

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.