File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed
Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 85.7 MB, 시간: 0.12 ms
7+ 메모리: 85.1 MB, 시간: 0.36 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 04월 16일 16:19:15
19+ 2025년 09월 01일 15:53:56
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 11import java .util .*;
22class Solution {
3- public int solution ( String [][] clothes ) {
4- Map < String , Integer > map = new HashMap <>();
5- // 종류별로 그룹화 , 기본값:1(아무것도 안입는 경우 포함: +1)
6- for ( int i = 0 ; i < clothes . length ; i ++){
7- String category = clothes [ i ][ 1 ];
8- map .put (category ,map .getOrDefault (category , 1 ) +1 );
3+ HashMap < String , Integer > map = new HashMap <>();
4+ public int solution ( String [][] clothes ) {
5+ for ( String [] cloth : clothes ){
6+ String type = cloth [ 1 ]; // 의상 종류
7+ // 의상 종류 별 가짓수 기록
8+ map .put (type ,map .getOrDefault (type , 0 ) +1 );
99 }
10-
11- int answer = 1 ;
12- for (int num :map .values ()){
13- answer *= num ;
10+
11+ int [] number = new int [map .size ()];
12+ int idx = 0 ;
13+ int total = 1 ;
14+ for (String key : map .keySet ()){
15+ int value = map .get (key );
16+ number [idx ++] = value ;
17+ total *= value + 1 ;
1418 }
15-
16- // 모든 종류의 옷을 안입는 경우 -1
17- answer --;
18- return answer ;
19+
20+ return total -1 ;
1921 }
2022}
You can’t perform that action at this time.
0 commit comments