Easiest and fastest c++ solution, space complexity **O(1)**, time complexity O(m*n)!


#1

//Make all reachable points as 1 and rest as 0 first and use dp in original vector A itself

int Solution::uniquePathsWithObstacles(vector<vector > &A) {

int i,j,t,m,n;
m=A.size();
n=A[0].size();


if(!A[0][0])
{
    A[0][0]=1;
}
else
    return 0;
    
    
for(j=1;j<n;j++)
{
    if(A[0][j])
    {
        for(int k=j;k<n;k++)
        {
            A[0][k]=0;
        }
        
        break;
    }
    else
    A[0][j]=1;
}

for(i=1;i<m;i++)
{
    if(A[i][0])
    {
        for(int k=i;k<m;k++)
        {
            A[k][0]=0;
        }
        break;
    }
    else
    A[i][0]=1;
}


for(i=1;i<m;i++)
{
    for(j=1;j<n;j++)
    {
        if(!A[i][j])
          A[i][j]=1;
        else
        A[i][j]=0;
    }
}

for(i=1;i<m;i++)
{
    for(j=1;j<n;j++)
    {
        if(A[i][j])
          A[i][j]=A[i][j-1]+A[i-1][j];
    }
}
return A[m-1][n-1];

}