의상들이 담긴 2차원 배열 clothes가 주어질 때 서로 다른 옷의 조합의 수를 return 하도록 solution 함수를 작성해주세요.
입출력 예시
clothes : [["yellowhat", "headgear"], ["bluesunglasses", "eyewear"], ["green_turban", "headgear"]]
-> 5
function solution(clothes) {
var answer = 1;
var cloth_map = new Map();
clothes.forEach((c) => {
if (c[1] in cloth_map) cloth_map[c[1]].push(c[0]);
else cloth_map[c[1]] = [c[0]];
})
for (var c in cloth_map) {
answer *= (cloth_map[c].length + 1);
}
return answer - 1;
}