```
public int UniquePathsWithObstacles(int[,] obstacleGrid)
{
int m = obstacleGrid.GetLength(0);
int n = obstacleGrid.GetLength(1);
int[] array = new int[n];
array[n-1] = 1;
for( int i = m-1; i >= 0; --i )
for( int j = n-1; j >=0 ; --j )
{
if( j +1 != n )
array[j] += array[j+1];
if( obstacleGrid[i,j] == 1 )
array[j] = 0;
}
return array[0];
}
```