uniqueCountSorted
uniqueCountSorted(
x):number
Defined in: src/unique_count_sorted.js:15
For a sorted input, counting the number of unique values is possible in constant time and constant memory. This is a simple implementation of the algorithm.
Values are compared with ===, so objects and non-primitive objects
are not handled in any special way.
Parameters
Section titled “Parameters”any[]
an array of any kind of value
Returns
Section titled “Returns”number
count of unique values
Example
Section titled “Example”uniqueCountSorted([1, 2, 3]); // => 3uniqueCountSorted([1, 1, 1]); // => 1