강의

멘토링

커뮤니티

Inflearn Community Q&A

junj's profile image
junj

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

6. Alpha Code (DFS)

다른 방법의 DFS

Written on

·

220

0

다음과 같이 DFS 함수를 작성하는 것도 괜찮은 방법일까요?

def DFS(L):
    global cnt
    if L == n_size:
        for x in result_list:
            print(x, end='')
        print()
        cnt += 1
        return
    else:
        for i in range(L, n_size):
            if n[L] != '0' and 65 <= int(n[L: i+1]) + 64 <= 90:
                result_list.append(chr(int(n[L: i+1])+ 64))
                DFS(i+1)
                result_list.pop()
dfspython알고리즘코테 준비 같이 해요! 코딩테스트

Answer

This question is waiting for answers
Be the first to answer!
junj's profile image
junj

asked

Ask a question