-
카테고리
-
세부 분야
알고리즘 · 자료구조
-
해결 여부
미해결
처리 방법 질문
21.10.17 17:20 작성 조회수 95
3
코드 배열 대신 문자열 상태를 유지하는 방법은 어떨지요?
def DFS(L, word):
global res
if L == n:
print(word)
res += 1
else:
a = int(code[L])
b = 0
if a == 0:
return
if L+1 < n:
b = int("".join(code[L:L+2]))
if a >= 1 and a <= 26:
DFS(L+1, word + chr(a+64))
if b >= 1 and b <= 26:
DFS(L+2, word + chr(b+64))
답변을 작성해보세요.
0
답변 1