java 프로그래머스 [해쉬] _위장
2021. 4. 29. 22:17ㆍ프로그래머스 알고리즘/코딩 테스트 고득점 Kit
반응형
출제 링크 : programmers.co.kr/learn/courses/30/lessons/42578
import java.util.HashMap;
class Solution {
public int solution(String[][] clothes) {
HashMap<String, Integer> hm = new HashMap<String, Integer>();
int answer = 1;
for (int i = 0; i < clothes.length; i++) {
hm.put(clothes[i][1], hm.getOrDefault(clothes[i][1], 1) + 1);
}
for (int i : hm.values()) {
answer *= i;
}
return answer - 1;
}
}
반응형