- 난이도: Lv2
프로그래머스 링크: https://school.programmers.co.kr/learn/courses/30/lessons/42578
풀이 링크(GitHub): hayannn/CodingTest_Java/프로그래머스/2/의상
풀이 시간 : 27분
import java.util.*;
import static java.util.stream.Collectors.*;
class Solution {
public int solution(String[][] clothes) {
Map<String, Long> categoryCount = Arrays.stream(clothes)
.collect(groupingBy(c -> c[1], counting()));
return categoryCount.values().stream()
.map(count -> count + 1)
.reduce(1L, (a, b) -> a * b)
.intValue() - 1;
}
}