So today’s task was so easy I’m going to do another one because I solved it way too fast. It’s really not that hard if you know some built-in data structures.

### Problem

Given an **n-length** Array of numbers between -1,000,000 to 1,000,000, find the number of distinct values in the array.

#### Example

A = [1,4,2,6,8,2,3,6] returns 6

### My Solution

The idea is to eliminate duplicated numbers from the Array. For this, we use a Set and then get the size of this set which finishes the solution.

```
const solution = A => new Set(A).size
```

And done.

I actually spent more time writing this than thinking about the solution😁.

## 0 Comments

## Leave a comment