[프로그래머스/Swift] 42578번 - 의상
문제https://school.programmers.co.kr/learn/courses/30/lessons/42578풀이조합으로 해결가능하다옷 종류에 따른 개수 + 해당 옷을 선택하지 않는 경우로 계산하면 된다최소 하나의 옷을 골라야하기 때문에 전체 경우의 수 - 1(아무것도 선택하지 않는 경우)로 계산한다전체코드import Foundationfunc solution(_ clothes:[[String]]) -> Int { var dics: [String:[String]] = [:] for clothe in clothes { //종류별 정리 if dics[clothe[1]] == nil { dics[clothe[1]] = [] } dics..
PS/문제 풀이
2025. 1. 26. 23:44
