Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
All Paths From Source to Target
Bookmark
Input
Diamond
Complex
Two nodes
Fan-out
Chain + skip
Custom
graph
=
[[1,2],[3],[3],[]]
0
0
1
1
2
2
3
3
source
target
0
0
1
1
2
2
3
3
source
target
0
0
1
1
2
2
3
3
source
target
current
node 0 points to
[1, 2]
0
0
1
1
2
2
3
3
source
target
current
memo[1]
miss, compute
0
0
1
1
2
2
3
3
source
target
current
memo[3]
miss, compute
0
0
1
1
×1
2
2
3
3
×1
source
target
current
memo[1] =
×1
path
0
0
1
1
×1
2
2
3
3
×1
source
target
current
follow
0 → 2
0→1→3
0
0
1
1
×1
2
2
3
3
×1
source
target
current
node 2 points to
[3]
0→1→3
0
0
1
1
×1
2
2
3
3
×1
source
target
current
[2]
+
[3]
=
[2,3]
0→1→3
0
0
1
1
×1
2
2
×1
3
3
×1
source
target
current
[0]
+
[2,3]
=
[0,2,3]
0→1→3
0→2→3
0
0
×2
1
1
×1
2
2
×1
3
3
×1
source
target
return 2
paths
0→1→3
0→2→3
algo
master
.
io
Step:
Find every path from node 0 to node 3 with DFS + memoization
0 / 29
Input
Diamond
Complex
Two nodes
Fan-out
Chain + skip
Custom
graph
=
[[1,2],[3],[3],[]]
0 / 29
algo
master
.
io
Step:
Find every path from node 0 to node 3 with DFS + memoization