import Foundation
func solution(_ clothes:[[String]]) -> Int {
let count = Set(clothes.compactMap({ $0.last })).map { type in
return clothes.filter { $0.last == type }.count + 1
}
return count.reduce(1) { $0 * $1 } - 1
}
'프로그래머스 > Lv.2' 카테고리의 다른 글
[Swift] 점프와 순간 이동 (0) | 2023.02.05 |
---|---|
[Swift] 이진 변환 반복하기 (0) | 2023.02.05 |
[Swift] 올바른 괄호 (0) | 2023.02.04 |
[Swift] 예상 대진표 (0) | 2023.02.04 |
[Swift] 영어 끝말잇기 (0) | 2023.02.04 |