dp and O(1) short javascript solution
\nvar uniquePathsWithObstacles = function(obstacleGrid) {\n    for(var i=0;i<obstacleGrid.length;i++){\n        for(var j=0;j<obstacleGrid[0].length;j++){\n    
```\nvar uniquePathsWithObstacles = function(obstacleGrid) {\n    for(var i=0;i<obstacleGrid.length;i++){\n        for(var j=0;j<obstacleGrid[0].length;j++){\n            if(obstacleGrid[i][j] == 1)\n                obstacleGrid[i][j] = 0\n            else if(i==0&&j==0)\n                obstacleGrid[0][0] = 1;\n            else\n                obstacleGrid[i][j] = (i>0? obstacleGrid[i-1][j] : 0) + (j>0 ? obstacleGrid[i][j-1] :0)\n        }\n    }\n    return obstacleGrid[obstacleGrid.length -1][obstacleGrid[0].length-1]\n};\n```
[]