๐ฆ ์คํฌํธ๋ฆฌ
1. ๋ฌธ์ ๋งํฌ
2. ์ฝ๋
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from copy import deepcopy
def solution(skill, skill_trees):
answer = 0
for skill_tree_case in skill_trees:
not_learned = deepcopy(skill) # ์ ํ ์คํฌํธ๋ฆฌ ๋ณต์ฌ
flag = True # ์คํฌํธ๋ฆฌ๋ฅผ ๋ง์กฑํ๋์ง ์ฌ๋ถ
for current_skill in skill_tree_case:
if not_learned:
# ํ์ฌ ์คํฌํธ๋ฆฌ๋ฅผ ๋ง์กฑํ๋ ์คํฌ์ ๋ฐฐ์
if current_skill == not_learned[0]:
not_learned = not_learned[1:]
# ํ์ฌ ์คํฌํธ๋ฆฌ๋ฅผ ๋ง์กฑํ์ง ๋ชปํ๋ ์คํฌ
elif current_skill in not_learned:
flag = False
break
if flag:
answer += 1
return answer
- ์ ํ์ฑ ์ฑ์ ์ ์์ํฉ๋๋ค. ์ ํ์ฑ ํ ์คํธ ํ ์คํธ 1 ใ ํต๊ณผ (0.01ms, 10.3MB) ํ ์คํธ 2 ใ ํต๊ณผ (0.01ms, 10.3MB) ํ ์คํธ 3 ใ ํต๊ณผ (0.01ms, 10.3MB) ํ ์คํธ 4 ใ ํต๊ณผ (0.01ms, 10.3MB) ํ ์คํธ 5 ใ ํต๊ณผ (0.01ms, 10.2MB) ํ ์คํธ 6 ใ ํต๊ณผ (0.01ms, 10.4MB) ํ ์คํธ 7 ใ ํต๊ณผ (0.03ms, 10.2MB) ํ ์คํธ 8 ใ ํต๊ณผ (0.01ms, 10.3MB) ํ ์คํธ 9 ใ ํต๊ณผ (0.01ms, 10.3MB) ํ ์คํธ 10 ใ ํต๊ณผ (0.01ms, 10.1MB) ํ ์คํธ 11 ใ ํต๊ณผ (0.02ms, 10.3MB) ํ ์คํธ 12 ใ ํต๊ณผ (0.02ms, 10.2MB) ํ ์คํธ 13 ใ ํต๊ณผ (0.03ms, 10.3MB) ํ ์คํธ 14 ใ ํต๊ณผ (0.01ms, 10.2MB) ์ฑ์ ๊ฒฐ๊ณผ ์ ํ์ฑ: 100.0 ํฉ๊ณ: 100.0 / 100.0
3. ํด์ค
๋ชจ๋ ์คํฌ ํธ๋ฆฌ์์ ์คํฌ ๊ฒฐ๊ณผ๊ฐ ์ ํ ์คํฌํธ๋ฆฌ ์์์ ํฌํจ๋์ด ์์ผ๋ฉด์, ์ ์ผ ์์ ์์ผ๋ฉด ๋ฐฐ์ธ ์ ์๊ณ ๊ทธ๋ ์ง ์์ผ๋ฉด ์๋ชป๋ ์คํฌํธ๋ฆฌ ์์๋ก ํ๋จํ์ฌ ํ์ถ
์ดํ ํ๋๊ทธ๋ฅผ ํตํด ์ฌ๋ฐ๋ฅธ ์คํฌํธ๋ฆฌ์ธ์ง ๊ฒ์ฌํ์ฌ ๊ฒฐ๊ณผ์ ๋ํ๋ค
This post is licensed under CC BY 4.0 by the author.