티스토리 뷰
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
- equals()
- HashMap
- 프로그래머스 알고리즘
- math.max
- 알고리즘
- easy algorithm
- hackerrank javascript solution
- HackerRank Algorithm
- hackerrank
- Javascript Algorithm
- java
- rest parameter
- C++
- 프로그래머스 알고리즘문제
- spring boot application
- easy javascript algorithm
- math.abs
- 프로그래머스
- substring()
- Collection Framework
- javascript
- hackerrank javascript
- compareTo()
- Object type casting
- hackerrank solution
- algorithm
- code refactoring
- ... in Javascript
- string class in java
- repeat()
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
글 보관함