프로그래머스 여행경로 - 백트래킹
def dfs(ans, routes, pointNum, answer, isFinished): if len(ans) == pointNum: if not isFinished[0]: for i in ans: answer.append(i) isFinished[0] = True return nexts = isPossible(ans[-1], routes) for next in nexts: if not isFinished[0]: next[1] = True ans.append(next[0]) dfs(ans, routes, pointNum, answer, isFinished) # 티켓 사용여부 False로 돌려놓음 next[1] = False ans.pop() def isPossible(start, routes): re..
더보기