Post

๐ŸฆŠ ์Šคํ‚ฌํŠธ๋ฆฌ

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.