알고리즘 유형 : 해시
풀이 참고 없이 스스로 풀었나요? : O
https://programmers.co.kr/learn/courses/30/lessons/42578
딕셔너리 풀이
def solution(clothes):
answer = 1
clothes_dict = {}
for cloth in clothes:
cloth_type = cloth[1]
if cloth_type in clothes_dict:
clothes_dict[cloth_type] += 1
else:
clothes_dict[cloth_type] = 2
for v in clothes_dict.values():
answer *= v
return answer - 1
Counter 모듈 풀이
from collections import Counter
def solution(clothes):
answer = 1
cloth_type = Counter([t for _, t in clothes])
for v in cloth_type.values():
answer *= (v+1)
return answer - 1
풀이 요약
배운 점, 어려웠던 점