의상

Tiffany ·2024년 3월 6일
0

Programmers

목록 보기
2/15
from collections import Counter 

def solution(clothes):
    count = {} # kind: item 
    answer = 1 
    for cloth in clothes:
        item, kind = cloth[0], cloth[1] 
        
        if kind in count:
            count[kind].append(item) 
        else:
            count[kind] = [item] 
        
    for i in count.keys():
            answer *= len(count[i])+1
            
        
    
    return answer -1 

    #yellow hat: head 
    #sunglasses: eye
    #turban: head 
    #head: yellow hat, turban 
    #eye: sunglasses 
    
    #answer = answer * (yellow hat, turban+1) = 3
    #answer = 3 * (sunglasses +1) = 6 
profile
Love what you do and don't quit.

0개의 댓글