Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Unique Paths II
Bookmark
Recursion
2D DP
Space-Optimized
Input
Example 1
Example 2
Example 3
No way through
Custom
grid
=
[[0,0,0],[0,1,0],[0,0,0]]
0,0
1,0
2,0
3,0
2,1
3,1
2,2
1,1
0,1
1,1
0,2
1,2
2,2
1,3
0,3
down to [2][0]
0,0
1,0
2,0
3,0
0
2,1
3,1
2,2
1,1
0,1
1,1
0,2
1,2
2,2
1,3
0,3
right to [2][1]
0,0
1,0
2,0
3,0
0
2,1
3,1
0
2,2
1,1
0,1
1,1
0,2
1,2
2,2
1,3
0,3
right to [2][2]
1
1
1
0,0
1,0
2,0
1
3,0
0
2,1
1
3,1
0
2,2
1
1,1
0,1
1,1
0,2
1,2
2,2
1,3
0,3
right to [1][1]
1
1
1
1
0,0
1,0
1
2,0
1
3,0
0
2,1
1
3,1
0
2,2
1
1,1
0
0,1
1,1
0,2
1,2
2,2
1,3
0,3
down to [1][1]
1
1
1
1
0,0
1,0
1
2,0
1
3,0
0
2,1
1
3,1
0
2,2
1
1,1
0
0,1
1,1
0
0,2
1,2
2,2
1,3
0,3
down to [1][2]
1
1
1
1
0,0
1,0
1
2,0
1
3,0
0
2,1
1
3,1
0
2,2
1
1,1
0
0,1
1,1
0
0,2
1,2
2,2
1
1,3
0,3
right to [1][3]
1
1
1
1
1
0,0
1,0
1
2,0
1
3,0
0
2,1
1
3,1
0
2,2
1
1,1
0
0,1
1,1
0
0,2
1,2
1
2,2
1
1,3
0
0,3
countPaths(0, 3)
2
1
1
1
1
1
1
1
0,0
2
1,0
1
2,0
1
3,0
0
2,1
1
3,1
0
2,2
1
1,1
0
0,1
1
1,1
0
0,2
1
1,2
1
2,2
1
1,3
0
0,3
0
2 path(s)
algo
master
.
io
Step:
Walk right or down from [0][0] to [2][2], avoiding walls
0 / 46
Input
Example 1
Example 2
Example 3
No way through
Custom
grid
=
[[0,0,0],[0,1,0],[0,0,0]]
0 / 46
algo
master
.
io
Step:
Walk right or down from [0][0] to [2][2], avoiding walls