版权声明:本文为博主原创文章,未经博主允许不得转载。(╰_╯)# https://blog.csdn.net/qq_36735489/article/details/82623428
class Solution(object):
def allPathsSourceTarget(self, graph):
"""
:type graph: List[List[int]]
:rtype: List[List[int]]
"""
res = []
tar = len(graph)-1
def dfs(start, path):
if start == tar:
res.append(path)
for node in graph[start]:
dfs(node, path+[node])
dfs(0, [0])
return res