Notice
Recent Posts
Recent Comments
Link
관리 메뉴

one by one ◼◻◼◻

위장 (프로그래머스 코딩테스트 연습-해시) 본문

코딩문제

위장 (프로그래머스 코딩테스트 연습-해시)

JihyunLee 2022. 6. 10. 19:32

 

1
2
3
4
5
6
7
8
9
10
11
12
from collections import defaultdict
 
 
def solution(clothes):
    clot = defaultdict(list)
    for item in clothes:
        clot[item[1]].append(clot[item[0]])
    
    answer = 1
    for key in clot.keys():
        answer *= (len(clot[key])+1)
    return answer-1
cs
Comments