생각해보니 번호는 별로 안 중요한거 같음https://leetcode.com/problems/all-paths-from-source-to-target/ All Paths From Source to Target - LeetCodeAll Paths From Source to Target - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.leetcode.comclass Solution: def allPathsSourceTarget(self, graph: List[List[int]]) -> List[List[int]]: queue = deque([]) ans = [] queue.append([0]) while queue: path = queue.popleft() cur = path[-1] for next in graph[cur]: if next == len(graph)-1 : ans.append(path + [next]) else : queue.append(path + [next]) return ansn이 크지 않고 DAG기 때문에 visit 배열 없이 그냥 BFS 돌리면 끝. 경로는 리스트로 관리. 파이썬 최고!
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.