240214 의상

Jongleee·2024년 2월 14일
0

TIL

목록 보기
495/576
public int solution(String[][] clothes) {
	HashMap<String, Integer> clothesMap = new HashMap<>();

	for (String[] clothe : clothes) {
		String type = clothe[1];
		clothesMap.put(type, clothesMap.getOrDefault(type, 0) + 1);
	}

	int totalCombinations = 1;
	for (int count : clothesMap.values()) {
		totalCombinations *= (count + 1);
	}

	return totalCombinations - 1;
}

출처:https://school.programmers.co.kr/learn/courses/30/lessons/42578

0개의 댓글