티스토리 뷰
const alphabets = [1,1,1,2,3,3,1,4,5];
const counts = alphabets.reduce((acc, current) => {
if(acc[current]){
acc[current] += 1;
} else {
acc[current] = 1;
}
return acc;
}, {});
console.log(counts); //{ '1': 4, '2': 1, '3': 2, '4': 1, '5': 1 }
'Algorithms' 카테고리의 다른 글
find intersection algorithm (0) | 2021.03.28 |
---|---|
two sum (0) | 2021.03.26 |
on sale products algorithm (0) | 2021.02.12 |
How many typos in a string (0) | 2021.02.12 |
CamelCase (0) | 2021.02.12 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- easy javascript algorithm
- 알고리즘
- 프로그래머스 알고리즘
- math.max
- string class in java
- hackerrank javascript solution
- C++
- equals()
- hackerrank javascript
- Javascript Algorithm
- spring boot application
- code refactoring
- HashMap
- easy algorithm
- HackerRank Algorithm
- Collection Framework
- rest parameter
- hackerrank solution
- 프로그래머스
- repeat()
- substring()
- 프로그래머스 알고리즘문제
- javascript
- java
- Object type casting
- ... in Javascript
- hackerrank
- algorithm
- compareTo()
- math.abs
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함