Compute number of distinct values in an array.
If we sort the array then we are simply able to step through it and keep a counter of every time a new number is encountered.
function solution(A) {
A.sort((a,b) => a-b)
let count = 0
let previous = null
A.forEach((e)=> {
if (previous !== e) {
count++
previous = e
}
})
return count
}