Development/Algorithm & Coding Test
[프로그래머스] 위장 - 파이썬(Python)
컴공 K
2022. 5. 6. 00:01
728x90
[프로그래머스] 위장 - 파이썬(Python)

from collections import defaultdict
def solution(clothes):
d = defaultdict(int)
for n, t in clothes:
d[t] += 1
answer = 1
for i in d.values():
answer *= (i + 1)
return answer - 1
- 특정 종류의 옷을 안입는 경우를 +1로 추가해주고 난 뒤, 맨 마지막에 모두 안입은 경우를 빼줌
https://programmers.co.kr/learn/courses/30/lessons/42578
코딩테스트 연습 - 위장
programmers.co.kr
728x90
반응형