C 0ms


  • 0
    Y
    #define MAX 101
    
    int uniquePathsWithObstacles(int** obstacleGrid, int obstacleGridRowSize, int obstacleGridColSize) {
    int i,j,path[MAX][MAX];
    i = 0;
     printf("hh");
    while(i<obstacleGridRowSize && obstacleGrid[i][0]==0)
        path[i++][0] = 1; 
    while(i<obstacleGridRowSize)
        path[i++][0] = 0;
    
    i = 0;
    while(i<obstacleGridColSize && obstacleGrid[0][i]==0 )
        path[0][i++] = 1;
    while(i<obstacleGridColSize)
        path[0][i++] = 0;
    
    for(i=1;i<obstacleGridRowSize;i++){
        for(j=1;j<obstacleGridColSize;j++){
            if(obstacleGrid[i][j]==1)
                path[i][j] = 0;
            else
                path[i][j] = path[i][j-1]+path[i-1][j];
        }
    }
    return path[obstacleGridRowSize-1][obstacleGridColSize-1];
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.