[파이썬/Python/프로그래머스] 해시 > 위장

SooYeon Yeon·2022년 8월 4일
0

파이썬/알고리즘

목록 보기
30/35

풀이

from collections import defaultdict
def solution(clothes):
    answer = 1
    clothes_dict = defaultdict(list)
    
    # dict 만들기
    for cloth in clothes:
        clothes_dict[cloth[1]].append(cloth[0])
    
    for value in clothes_dict.values():
        answer *= (len(value)+1)
    answer -= 1
    return answer

0개의 댓글