Challenge 5: Print all Paths Between Two Nodes

Given a graph, print all paths that exist between two nodes

Problem Statement

Implement a function that prints all paths that exist between two nodes (source to destination).

Input

A graph, a source value, and a destination value.

Output

A list of strings specifying all paths

Sample Input

graph = {
    0 -> 1
    1 -> 2
    1 -> 5
    2 -> 3
    2 -> 4
    5 -> 3
    5 -> 6
    3 -> 6
}

source = 0
destination = 6

Sample Output

0 1 5 6
0 1 5 3 6
0 1 2 3 6

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.