프로그래머스 [의상]
문제보기

소스코드
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class Solution {
public int solution(String[][] clothes) {
Map<String, List<String>> clothesMap = new HashMap<>();
for (int i = 0; i < clothes.length; i++) {
clothesMap.computeIfAbsent(clothes[i][1], key -> new ArrayList<>()).add(clothes[i][0]);
}
int answer = 1;
for (Map.Entry<String, List<String>> entry : clothesMap.entrySet()) {
answer *= (entry.getValue().size() + 1);
}
answer -= 1; // 깨댕이 제외
return answer;
}
}