Skip to content

Commit cb614bc

Browse files
committed
Update solution 063 [Python3]
1 parent a4c2367 commit cb614bc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution(object):
2+
def uniquePathsWithObstacles(self, obstacleGrid):
3+
"""
4+
:type obstacleGrid: List[List[int]]
5+
:rtype: int
6+
"""
7+
m, n = len(obstacleGrid), len(obstacleGrid[0])
8+
martix = [[0] * n] * m
9+
for i in range(m):
10+
for j in range(n):
11+
if obstacleGrid[i][j] == 1:
12+
martix[i][j] = 0
13+
else:
14+
if i == 0 and j == 0:
15+
martix[i][j] = 1
16+
elif i == 0:
17+
martix[i][j] = martix[i][j - 1]
18+
elif j == 0:
19+
martix[i][j] = martix[i - 1][j]
20+
else:
21+
martix[i][j] = martix[i - 1][j] + martix[i][j - 1]
22+
return martix[m - 1][n - 1]

0 commit comments

Comments
 (0)