Skip to content

Commit 25d89e7

Browse files
authored
Create 62-Unique-Paths.py
1 parent 6648621 commit 25d89e7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

62-Unique-Paths.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def uniquePaths(self, m: int, n: int) -> int:
3+
row = [1] * n
4+
5+
for i in range(m - 1):
6+
newRow = [1] * n
7+
for j in range(n - 2, -1, -1):
8+
newRow[j] = newRow[j + 1] + row[j]
9+
row = newRow
10+
return row[0]
11+
12+
# O(n * m) O(n)

0 commit comments

Comments
 (0)