프로그래머스 해시. 위장 파이썬 풀이

minan·2021년 6월 20일
0

프로그래머스

목록 보기
9/92

프로그래머스 해시 Level 2. 위장 파이썬 풀이

문제 링크 https://programmers.co.kr/learn/courses/30/lessons/42578

옷을 입지 않는 경우까지 고려하여 +1을하여 계산해주고
모든 옷을 입지 않는 경우를 빼준다.

from collections import defaultdict

def solution(clothes):
    answer = 1
    
    dic = defaultdict(int)
    
    # 종류 +1
    for cloth, kind in clothes:
        dic[kind] += 1

    for value in dic.values():
        answer *= (value+1)

    return answer-1
profile
https://github.com/minhaaan

0개의 댓글