class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { for(int i=0;i=0?1:0; for(int i=0;i =0) obstacleGrid[i][j]+=(i>0&&obstacleGrid[i-1][j]>=0?obstacleGrid[i-1][j]:0)+(j>0&&obstacleGrid[i][j-1]>=0?obstacleGrid[i][j-1]:0); return Math.max(obstacleGrid[obstacleGrid.length-1][obstacleGrid[0].length-1], 0); }}