Skip to content

Commit c4805c1

Browse files
author
sangbeenmoon
committed
solved unique-paths.
1 parent 03c9cc3 commit c4805c1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

unique-paths/sangbeenmoon.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# dp[r][c] = dp[r-1][c] + dp[r][c-1]
2+
3+
class Solution:
4+
def uniquePaths(self, m: int, n: int) -> int:
5+
dp = [[1] * n for _ in range(m)]
6+
7+
for r in range(m):
8+
for c in range(n):
9+
if r == 0 or c == 0:
10+
continue
11+
dp[r][c] = dp[r-1][c] + dp[r][c-1]
12+
13+
return dp[m-1][n-1]

0 commit comments

Comments
 (0)