문제 설명
해결과정
Solution.java
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
int answer = 0;
HashMap<String, Integer> clothesCount = new HashMap<String, Integer>();
for(int i = 0; i < clothes.length; i++) {
if(clothesCount.containsKey(clothes[i][1])) {
clothesCount.put(clothes[i][1], clothesCount.get(clothes[i][1])+1);
} else {
clothesCount.put(clothes[i][1], 1);
}
}
Collection<Integer> values = clothesCount.values();
int multi = 1;
for (Integer value : values) {
multi *= (value+1);
}
System.out.println(multi-1);
answer = multi - 1;
return answer;
}
}
Java
복사