Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Number of Ways to Arrive at Destination
Bookmark
Input
Standard
Small
Diamond
Custom
n
=
7
,
roads
=
[[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]
7
2
3
3
3
1
1
1
5
2
0
1
2
3
4
5
6
start
dest
heap
dist
0
0
1
∞
2
∞
3
∞
4
∞
5
∞
6
∞
ways
0
1
1
0
2
0
3
0
4
0
5
0
6
0
ways[6] = 0
count the shortest paths from
0
to
6
algo
master
.
io
Step:
Count the shortest paths from node 0 to node 6
0 / 45
Input
Standard
Small
Diamond
Custom
n
=
7
,
roads
=
[[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]
0 / 45
7
2
3
3
3
1
1
1
5
2
0
1
2
3
4
5
6
start
dest
heap
dist
0
0
1
∞
2
∞
3
∞
4
∞
5
∞
6
∞
ways
0
1
1
0
2
0
3
0
4
0
5
0
6
0
ways[6] = 0
count the shortest paths from
0
to
6
algo
master
.
io
Step:
Count the shortest paths from node 0 to node 6