净喜欢给些非法的输入,各种边界条件,真是无语,注重细节就好,这种题真无聊
class Solution(object):
def uniquePathsWithObstacles(self, obstacleGrid):
"""
:type obstacleGrid: List[List[int]]
:rtype: int
"""
m=len(obstacleGrid)
if m==0:return 0
n=len(obstacleGrid[0])
if n==0:return 0
if obstacleGrid[0][0]==1 or obstacleGrid[m-1][n-1]==1:return 0
if m==1 or n==1:
for i in range(m):
for j in range(n):
if obstacleGrid[i][j]==1:return 0
for i in range(m):
if obstacleGrid[i][0]==0:
obstacleGrid[i][0]=10
else:
break
for j in range(1,n):
if obstacleGrid[0][j]==0:
obstacleGrid[0][j]=10
else:
break
#print obstacleGrid
for i in range(1,m):
for j in range(1,n):
if obstacleGrid[i][j]==1:continue
obstacleGrid[i][j]=(obstacleGrid[i-1][j]+obstacleGrid[i][j-1])/10*10
return obstacleGrid[m-1][n-1]/10