Skip to content

Commit 0e478e5

Browse files
iamAntimPalAntim-IWPIamShiwangi
committed
Update 62. Unique Paths.py
Co-Authored-By: Antim-IWP <203163676+Antim-IWP@users.noreply.github.com> Co-Authored-By: Shiwangi Srivastava <174641070+IamShiwangi@users.noreply.github.com>
1 parent 24ed128 commit 0e478e5

File tree

1 file changed

+11
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)