Problem Solving/Programmers
[Level 2] 위장
kmkunk
2022. 4. 6. 11:25
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
int answer = 1;
Map<String, Integer> map = new HashMap<>();
for(int i=0; i<clothes.length; i++) { map.put(clothes[i][1], 1); }
for(int i=0; i<clothes.length; i++) {
int value = map.get(clothes[i][1])+1;
map.put(clothes[i][1], value);
}
for(int i : map.values()) { answer *= i; }
return answer-1;
}
}