Algorithms / Programmers / 위장

Onam Kwon·2022년 4월 20일
0

Algorithms

목록 보기
12/24

링크

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

풀이

Get rid of the case that is all clothes are not put on.

코드

def solution(clothes):
    d = {}
    for item in clothes:
        if item[1] in d:
            d[item[1]].append(item[0]) 
        else:
            d[item[1]] = [item[0]]
    l = []
    for key in d:
        l.append(len(d[key])+1)
    answer = 1
    for item in l:
        answer *= item
    # get rid of the case that is all clothes are not put on
    return answer-1
profile
권오남 / Onam Kwon

0개의 댓글