알고리즘
[Java]프로그래머스 위장
irerin07
2019. 4. 15. 21:24
728x90
```
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
int answer = 0;
HashMap<String, Integer> hm = new HashMap<String, Integer>();
for(int i =0; i<clothes.length; i++) {
String key = clothes[i][1];
if(!hm.containsKey(key)) {
hm.put(key, 1);
}else {
hm.put(key, hm.get(key)+1);
}
}
System.out.println(hm);
int tempans = 1;
for(int a: hm.values()) {
tempans *= a + 1;
}
answer = tempans - 1;
return answer;
}
}
```
문제를 잘 이해하지 못해서 초반에 고생 한 문제
문제만 잘 이해하면 그렇게 어려운 문제가 아니다
728x90