Skip to content

Commit 0aadd19

Browse files
author
Eric
committed
85차 3번 문제풀이
1 parent 8b45d0a commit 0aadd19

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

live8/test85/문제3/황장현.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function solution(clothes) {
2+
let answer = 1;
3+
const dic = {};
4+
5+
for (let i = 0; i < clothes.length; i++) {
6+
const kind = clothes[i][1];
7+
if (dic[kind] !== undefined) {
8+
dic[kind] += 1;
9+
} else {
10+
dic[kind] = 1;
11+
}
12+
}
13+
14+
for (let k in dic) {
15+
answer *= dic[k] + 1;
16+
}
17+
18+
answer -= 1;
19+
return answer;
20+
}
21+
22+
console.log(
23+
solution([
24+
['yellow_hat', 'headgear'],
25+
['blue_sunglasses', 'eyewear'],
26+
['green_turban', 'headgear'],
27+
])
28+
);

0 commit comments

Comments
 (0)