Back to problems

Find All Paths from Source to Target in DAG

Algorithm · Bloomberg · Medium

You are given a directed acyclic graph represented by adjacency lists. Produce every possible route from the starting vertex to the ending vertex, in any sequence. Vertices are numbered from 0 through n - 1; vertex 0 is the source, while vertex n - 1 is the destination. Example The three listed routes are the only ways to travel from node 0 to node 4.

Checking your access…