728x90
반응형
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
HashMap<String, Integer> clo = new HashMap<>();
int[] num = new int[30];
int answer = 0;
for(int i = 0 ; i < clothes.length ; i++){
clo.put(clothes[i][1], clo.getOrDefault(clothes[i][1], 0) + 1);
}
int a = 0;
for(String keys : clo.keySet()){
num[a] = clo.get(keys) + 1;
a++;
}
for(int i = 0 ; i < a ; i++){
if(i==0){
answer = num[i];
}else{
answer *= num[i];
}
}
return (answer-1);
}
}
728x90
반응형
댓글