All Paths From Source to Target
1 | Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order. |
直接从0节点,DFS找到N-1就行了。因为是无环图也不需要判断有没有遍历过。
在找的时候会有重复的节点被找多次,可以采用Map<Integer,List<List
这种会重复路径的问题,类似DP,要记得试着去记录下来