공부기록/프로그래머스
[프로그래머스] 의상
메델
2023. 12. 19. 04:22
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
int answer = 1;
HashMap<String, Integer> hashmap = new HashMap<>();
for(String[] c: clothes){
String category = c[1];
hashmap.put(category, hashmap.getOrDefault(category,0)+1);
}
for(int x: hashmap.values()){
answer *= (x+1);
}
//아무것도 입지 않는 경우 제외
return answer-1;
}
}