본문 바로가기

열정가득한 개발자의 이야기/Javascript Algorithm

1207. Unique Number of Occurrences (Javascript)

 

Hi... I have another array problem.
The level is easy, but it is hard for me.
However, I won't give up; I'll do my best.

 

Anyway, to summarize this problem, I just need to check the unique count.

So, I used the Map object and Set.

 

Here is my answer.

 

First, I convert the array to a Map, where the Map is [key, value], so I add the count as the value.

Then, I initialize the Set because a Set can check for duplicated values.

Since that characteristic, I can check for duplicate factors.