Algobase
Problems
Get Premium
Pricing
Problems
/
62. Unique Paths
Prev
Next
Visualizer
Problem
Solution
Code
3 x 7 Grid
2 x 2 Grid
1 x 5 Grid
4 x 3 Grid
⌥
Visualizer will appear here
Problem
Solution
Code
1
def unique_paths(m, n):
2
dp = [[1] * n for _ in range(m)]
3
for row in range(1, m):
4
for col in range(1, n):
5
dp[row][col] = dp[row - 1][col] + dp[row][col - 1]
6
return dp[-1][-1]
Visualizer
3 x 7 Grid
2 x 2 Grid
1 x 5 Grid
4 x 3 Grid
⌥
Visualizer will appear here