All Paths From Source to Target
Medium · Graphs · about 15 minutes
Asked at Google, Amazon, Meta, Bloomberg, Netflix.
Given a directed acyclic graph of n nodes 0..n-1 (graph[i] lists the nodes i points to), return every path from node 0 to node n - 1, in any order.