|
์ฝ๋ ์์ฑํ๊ธฐ
def solution(clothes):
answer = 1
dic = {}
for i in clothes:
if i[1] in dic:
dic[i[1]] = dic[i[1]] + 1
else:
dic[i[1]] = 1
for i in dic.values():
answer *= (i+1)
return answer - 1
Python
๋ณต์ฌ
|
์ฝ๋ ์ค๋ช
ํ๊ธฐ
์ด ๋ฌธ์ ๋ hash๋ฌธ์ ๋ก dictionary๋ฅผ ํ์ฉํ์ฌ ์ฝ๊ฒ ํ ์ ์๋ค.
1.
๊ฐ ์์์ ์ด๋ฆ์ key๋ก ํ์ฌ ์์์ ์ข
๋ฅ์ ๊ฐ์๋ฅผ dic์ ์ ์ฅํ๋ค.
2.
dic์ ๊ฐ๋ค์ ๋ชจ๋ answer์ ๊ณฑํ๋ค.
3.
์ต์ ํ ๊ฐ์ ์์์ ์
๊ธฐ ๋๋ฌธ์ ๋ชจ๋ ์ ํ ์ํ๋ ๊ฒฝ์ฐ๋ฅผ ๋นผ์ค๋ค.