Skip to content

Commit 5c7a90e

Browse files
committed
해시
1 parent 4179687 commit 5c7a90e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

PROGRAMMERS/해시/위장.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function solution(clothes) {
2+
const cmap = new Map();
3+
clothes.forEach((c) => {
4+
const [name, category] = c;
5+
cmap.set(category, (cmap.get(category) || 0) + 1);
6+
});
7+
8+
// 전체 경우의 수 = (상의갯수+1) * (모자갯수+1) ... - 1(아무것도 선택되지 않았을 때)
9+
return (
10+
[...cmap.values()].reduce((acc, cur) => {
11+
return acc * (cur + 1);
12+
}, 1) - 1
13+
);
14+
}

0 commit comments

Comments
 (0)