Skip to content

Commit cdc320b

Browse files
committed
1 parent f81ef13 commit cdc320b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Hongjoo/lv2/피로도_재시도.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def solution(k, dungeons):
2+
max_count = 0
3+
def brutefoce(path, life):
4+
nonlocal max_count
5+
for idx in range(len(dungeons)):
6+
# (유망 여부) 조건에 안 맞으면 건너뛰기 : limit 제한 , 중복 탐사 방지
7+
if dungeons[idx][0] <= life and idx not in path:
8+
# 3. 탐색할 노드 선택 - 상태 변화
9+
path.append(idx)
10+
# 4. 재귀 호출(담 단계) - 자식 노드로 이동
11+
brutefoce(path ,life -dungeons[idx][1])
12+
# 5. 선택 취소 - 부모 노드로 복귀
13+
path.pop()
14+
max_count = max(max_count , len(path))
15+
brutefoce([], k )
16+
17+
return max_count

0 commit comments

Comments
 (0)