Skip to content

Commit 1ae8e4a

Browse files
committed
Beat 89.63% in runtime and 47.37% in memory
1 parent 27524b5 commit 1ae8e4a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

62. Unique Paths.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def uniquePaths(self, m, n):
3+
# array[i][j] store the possible unique paths to the point i, j
4+
# Base case :
5+
array = [[0 for i in range(n)] for j in range(m)]
6+
for i in range(n):
7+
array[0][i] = 1
8+
9+
for i in range(m):
10+
array[i][0] = 1
11+
12+
for i in range(1, m):
13+
for j in range(1, n):
14+
array[i][j] = array[i - 1][j] + array[i][j - 1]
15+
16+
return array[m - 1][n - 1]

0 commit comments

Comments
 (0)