Python solution without recursion


#1
def uniquePathsWithObstacles(self, A):
    n = len(A) 
    m = len(A[0])
    
    for i in range(n-1, -1, -1):  # start from bottom right
        for j in range(m-1, -1, -1):
            if A[i][j] == 1: # if obstacle, there are 0 ways from there
                A[i][j] = 0
            elif i == n-1 and j == m-1: # last step, there is 1 way (if not obstacle)
                A[i][j] = 1
            elif i == n-1: # can move only down
                A[i][j] = A[i][j+1]
            elif j == m-1: # can move only right
                A[i][j] = A[i+1][j]
            else:
                A[i][j] = A[i+1][j] + A[i][j+1] # can move down and right
                
    return A[0][0]