All Paths From Source to Target

Medium
Graphs Graph Backtracking BFS DFS

Find all paths from node 0 to node n-1 in DAG. Each path on one line.

Constraints

2 ≤ n ≤ 15

Examples

Example 1:
Input: 1,2 3 3
Output: 0 1 3 0 2 3
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.