
최소 1개는 입어야 한다고 했으니
모든 옷 종류+1을 각각 곱해준 후 1을 빼면 정답이다
쉽게 맞출 수 있었다 :)
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
int answer = 1;
Map<String, Integer> clothMap = new HashMap<>();
for(int i = 0; i < clothes.length; i++) {
String cloth = clothes[i][1];
if(clothMap.containsKey(cloth)) {
clothMap.put(cloth, clothMap.get(cloth)+1);
} else {
clothMap.put(cloth, 0);
}
}
Collection<Integer> values = clothMap.values();
for(Integer i : values) answer *= (i+2);
return answer-1;
}
}