https://programmers.co.kr/learn/courses/30/lessons/42578?language=java
import java.util.*;
class Solution {
public int solution(String[][] clothes) {
int answer = 1;
int cnt = 0;
List<String> Kinds = new ArrayList<>(); // μ·μ μ’
λ₯λ₯Ό λ΄μ 리μ€νΈ
for (int i = 0; i < clothes.length; i++) {
// μ€λ³΅νμ§ μμ κ²½μ° add
if (!Kinds.contains(clothes[i][1])) Kinds.add(clothes[i][1]);
}
int b[] = new int[Kinds.size()]; //ν΄λΉ μ· μ’
λ₯μ μλ₯Ό λ΄μ λ°°μ΄
for (int i = 0; i < b.length; i++) {
for (int k = 0; k < clothes.length; k++) {
// ν΄λΉν κ²½μ° ++
if (Kinds.get(i).equals(clothes[k][1])) cnt++;
}
b[i] = cnt + 1;
cnt = 0; // μ΄κΈ°ν
}
for (int i = 0; i < b.length; i++) {
answer *= b[i];
}
answer -= 1; // μ λΆλ€ μ ννμ§ μμκ²½μ° μ¦, μ무κ²λ μ°©μ©νμ§ μμκ²½μ°
return answer;
}
}