牛客有毒啊,一样的代码,一样的用例,在本地pycharm运行答案正确,牛客运行答案错误。。。
而且那测试用例是什么鬼,不是输入数组不是0就是1吗?整一堆A是几个意思。。。
class Solution: def uniquePathsWithObstacles(self , obstacleGrid: List[List[str]]) -> int: m = len(obstacleGrid) n = len(obstacleGrid[0]) dp = [[0] * n for i in range(m)] if obstacleGrid[0][0] == 0: return 0 else: dp[0][0] = 1 for i in range(1,m): if obstacleGrid[i][0] ==0: break dp[i][0] = 1 for j in range(1,n): if obstacleGrid[0][j] ==0: break dp[0][j] = 1 for i in range(1,m): for j in range(1,n): if obstacleGrid[i][j] ==1: dp[i][j] = dp[i-1][j]+dp[i][j-1] return dp[m-1][n-1]