Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Unique Paths II
Bookmark
Input
Example 1
Example 2
Example 3
No way through
Custom
grid
=
[[0,0,0],[0,1,0],[0,0,0]]
grid =
3x3
start
end
move only right or down; crossed cells are walls
grid =
3x3
start
end
move only right or down; crossed cells are walls
grid =
3x3
start
end
1
dp[0][0]
=
1
one way to stand at the start
grid =
3x3
start
end
1
1
1
i = 2
dp[2][0] =
1
copy from above
grid =
3x3
start
end
1
1
1
1
j = 1
dp[0][1] =
1
copy from the left
grid =
3x3
start
end
1
1
1
1
1
j = 2
dp[0][2] =
1
copy from the left
grid =
3x3
start
end
1
1
1
1
1
i = 1
j = 1
wall at [1][1]
: no path passes through, dp stays
0
grid =
3x3
start
end
1
1
1
1
1
1
i = 1
j = 2
dp[1][2] =
1
(top) +
0
(left) =
1
grid =
3x3
start
end
1
1
1
1
1
1
i = 2
row 2
each open cell adds top + left
grid =
3x3
start
end
1
1
1
1
1
1
1
2
i = 2
j = 2
dp[2][2] =
1
(top) +
1
(left) =
2
grid =
3x3
start
end
1
1
1
1
1
1
1
2
2
unique paths around the walls
algo
master
.
io
Step:
Same walk, right or down only, but now some cells are walls
0 / 12
Input
Example 1
Example 2
Example 3
No way through
Custom
grid
=
[[0,0,0],[0,1,0],[0,0,0]]
0 / 12
algo
master
.
io
Step:
Same walk, right or down only, but now some cells are walls