108. Count Distinct Elements
Core1000 ms256 MBSolved by 0%
Print how many distinct values the array contains.
For [1, 2, 2, 3, 3, 3] the answer is 3.
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains an integer n.
The second line contains n space-separated integers.
Output
Print one integer — how many distinct values the array contains.
Input6
1 2 2 3 3 3
Output3
Noteis the worked example from the statement
Input4
1 2 3 4
Output4
Notehas no repeats at all
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution