We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 87180a0 commit ee548e9Copy full SHA for ee548e9
1 file changed
Hongjoo/lv2/멀리뛰기.py
@@ -0,0 +1,22 @@
1
+answer = 0
2
+def solution(n):
3
+
4
+ def backtracking(path,lv):
5
+ # 재귀 종료
6
+ global answer
7
+ if lv >= len(path):
8
+ if sum(path)==n :
9
+ answer += 1
10
+ # print(f"{lv} : {path} >{answer}")
11
+ return 0
12
+ #자식 노드 이동
13
+ for x in [1,2] :
14
+ if sum(path) + x <= n :
15
+ path[lv] = x
16
+ backtracking(path , lv+1)
17
+ # backtracking
18
+ path[lv] = 0
19
20
+ for m in range(1,n+1) :
21
+ backtracking([0]*m , 0)
22
+ return answer%1234567
0 commit comments