Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6aeabf0

Browse files
Added Python solution for 62. Unique Paths (#118)
* Added Python solution for 62. UniquePaths * Changes added to Python solution for 62. UniquePaths
1 parent 23dabe3 commit 6aeabf0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
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+
bottom_row = [1] * n
4+
5+
for column in range(m - 1):
6+
new_row = [1] * n
7+
8+
for i in range(n - 2, -1, -1):
9+
new_row[i] = new_row[i + 1] + bottom_row[i]
10+
bottom_row = new_row
11+
12+
return bottom_row[0]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /