[Python] 프로그래머스 위장
·
알고리즘
위장해시를 사용하는 문제 풀이def solution(clothes): hash = {} # hash를 초기화 => {"옷 종류" : 0} for n, t in clothes: hash[t] = 0 # 옷 종류별로 가진 옷의 수를 해시에 넣음 for key in hash.keys(): cnt = 0 for n, t in clothes: if key == t: cnt += 1 hash[key] = cnt value = list(hash.values()) # [2, 1] ans = 1 # 경우의 수를 계산 for i in value: ..