Combination
- A: 4, B: 3, C;5 를 조합할때, 1~3개의 조합 경우의수 구하기 ★★★
- (A+1)*(B+1)*(C+1) = ABC + AB + BC + CA + A + B + C + 1 ※ 모두 고르지 않는 경우인 상수는 제외.
- Solution : ( 4 + 1 ) * ( 3 + 1 ) * ( 5 + 1 ) -1
import java.util.*;
class Solution {
static int answer = 1;
public int solution(String[][] clothes) {
HashMap<String,Integer> hm = new HashMap<String,Integer>();
for(int i=0;i<clothes.length;i++){
hm.put(clothes[i][1], hm.getOrDefault(clothes[i][1], 0)+1);
}
for(Integer e : hm.values()) answer*=e+1;
answer--;
return answer;
}
}