728x90
https://school.programmers.co.kr/learn/courses/30/lessons/42578
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
int answer = 1;
Map<String,Integer> map = new HashMap<>();
for(String[] arr : clothes){
String cloth = arr[1];
if(map.containsKey(cloth)){
int count= map.get(cloth) +1;
map.remove(cloth);
map.put(cloth,count);
}else{
map.put(cloth,1);
}
}
Iterator<Integer> iterator = map.values().iterator();
while(iterator.hasNext()){
answer *= iterator.next()+1;
}
return answer-1;
}
}
아래와 풀이 거의 일치
2024.10.31 - [🐣 알고리즘 삐약/💻 백준 삐약] - 104 삐약 : 백준 9375 | 패션왕 신혜빈 [바킹독| HASH |JAVA]
728x90
'🐣 알고리즘 삐약 > ✏️ 냅다 덤벼보는 문제풀이' 카테고리의 다른 글
[프로그래머스] 같은 숫자는 싫어 | 스택/큐 | lv.1 | JAVA (0) | 2024.10.31 |
---|---|
[프로그래머스] 베스트앨범 | 해시 | lv.3 | JAVA (0) | 2024.10.31 |
[프로그래머스] 전화번호 목록 | 해시 | lv.2 | JAVA (0) | 2024.10.31 |
[프로그래머스] 완주하지 못한 선수 | 해시 | lv.1 | JAVA (0) | 2024.10.31 |
[프로그래머스] 폰켓몬 | 해시 | lv.1 | JAVA (0) | 2024.10.31 |