We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9d2729e commit 64adb37Copy full SHA for 64adb37
62-unique-paths/unique-paths.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ def uniquePaths(self, m: int, n: int) -> int:
3
+ dp = [[0] * m for _ in range(n)]
4
+
5
+ for i in range(len(dp)):
6
+ dp[i][0] = 1
7
8
+ for i in range(len(dp[0])):
9
+ dp[0][i] = 1
10
11
+ for i in range(1, len(dp)):
12
+ for j in range(1, len(dp[i])):
13
+ dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
14
15
+ return dp[n - 1][m - 1]
0 commit comments