Summarize : just counting the Maximun Frequency
so I use a Map to keep track of the counts
i store the elements in an Array as keys, and their counts as values.
Here is my code, and it feels too long, so I'm not satisfied with it.
so i ask to Gpt for refactoring.
and here is the answer.
the code by gpt looks better than mine...
and I learned something new, such as the nullish coalescing operator.
It returns the value on the right-hand side if the left-hand side is null or undefined
'열정가득한 개발자의 이야기 > Javascript Algorithm' 카테고리의 다른 글
1207. Unique Number of Occurrences (Javascript) (0) | 2024.09.29 |
---|---|
392. Is Subsequence (Javascript) (0) | 2024.09.23 |
58. Length of Last Word (Javascript) (1) | 2024.09.22 |