Count Unique Numbers
easy
Given an array of integers, your task is to count the number of unique integers in the array.
Example 1
Input
[ [ 1, 2, 3, 1, 2 ] ]
Output
3
Explanation. The array contains three unique numbers: 1, 2, and 3.
Example 2
Input
[ [ -1, -1, -1, -1 ] ]
Output
1
Explanation. The array contains only one unique number: -1.
Example 3
Input
[ [ 7 ] ]
Output
1
Explanation. The array contains one unique number: 7.
Example 4
Input
[ [ 34, 78, 9, 0, 34, 78, 12 ] ]
Output
5
Explanation. The array contains five unique numbers: 34, 78, 9, 0, and 12.
Follow-up: How would you optimize your solution if the array contains many repeated elements?
Constraints:
1. The input array can contain both positive and negative integers, including zero.\n2. The array length will be at least 1 and at most 1000.