问题已解决,原因是多了个}
func uniquePathsWithObstacles(obstacleGrid [][]int) int {
m :=len(obstacleGrid[:][0])
n :=len(obstacleGrid[0][:])
var i,j int
for a :=0;i<m;i++ {
for b :=0;j<n;j++ {
switch obstacleGrid[a][b] {
case 1: obstacleGrid[a][b]=0
case 0 :obstacleGrid[a][b]=1
}
}
}
for i=1;i<m;i++ {
for j=1;j<n;j++ {
if obstacleGrid[i][j]!=0 {
obstacleGrid[i][j]=obstacleGrid[i-1][j]+obstacleGrid[i][j-1]
}
}
}
return obstacleGrid[m-1][n-1]
}
有疑问加站长微信联系(非本文作者)