Skip to content

Commit 3ca64ba

Browse files
committed
solve: unique paths
1 parent 0b0bb1b commit 3ca64ba

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

unique-paths/evan.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def uniquePaths(self, m: int, n: int) -> int:
3+
dp = [[1] * n for _ in range(m)]
4+
5+
# Iterate over the grid starting from 1,1 to fill the number of unique paths for each cell
6+
for i in range(1, m):
7+
for j in range(1, n):
8+
dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
9+
10+
return dp[m - 1][n - 1]

0 commit comments

Comments
 (0)