We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a4c2367 commit cb614bcCopy full SHA for cb614bc
solution/063.Unique Paths II/Solution.py
@@ -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
21
+ martix[i][j] = martix[i - 1][j] + martix[i][j - 1]
22
+ return martix[m - 1][n - 1]
0 commit comments