다시
function solution(clothes) {
var answer = 1;
let v = clothes.reduce( (a,b) => {
a[b[1]] = (a[b[1]] || 0)+1
return a
},{})
for(var key in v){
answer *= v[key] + 1;
}
return answer-1;
}
function solution(clothes) {
return Object.values(clothes.reduce((obj, t)=> {
obj[t[1]] = obj[t[1]] ? obj[t[1]] + 1 : 1;
return obj;
} , {})).reduce((a,b)=> a*(b+1), 1)-1;
}
function solution(clothes) {
const types = {};
for(const [style, type] of clothes){
if(type in types) types[type] +=1;
else types[type] = 1;
}
let sum = 1;
for(const type in types) sum *= (types[type] + 1)
return sum -1;
}
function solution(clothes) {
const map = new Map();
let count = 1;
for(let [c,t] of clothes){
if(map.has(t)) map.set(t, map.get(t)+1);
else map.set(t, 1);
}
for(let x of map.values()) count*=(x+1);
return count-1;
}