We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4179687 commit 5c7a90eCopy full SHA for 5c7a90e
1 file changed
PROGRAMMERS/해시/위장.js
@@ -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