프로그래머스 위장

박성호·2021년 7월 10일

(https://programmers.co.kr/learn/courses/30/lessons/42578?language=python3)
딕셔너리를 아는가? 그렇다면 이문제를 쉽게 접근하여 풀수있다.
딕셔너리로 의상의 종류가 없다면 1 있다면 +1을하여 마지막에 곱하여 문제를 풀면 매우 간단하게 이문제를 해결할수있다.!

def solution(clothes):
    answer={}
    for i in clothes:
        if i[1] in answer:
            answer[i[1]]+=1
        else:
            answer[i[1]]=1
    total=1
    for i in answer.values():
        total*=(i+1)
    return total
        
profile
코린이

0개의 댓글