Weird Behavior - Runtime Error on the last input


  • 1
    N
    if (obstacleGrid.size() == 0 || obstacleGrid[0].size() == 0)
                return 0;
            int rows = obstacleGrid.size();
            int columns = obstacleGrid[0].size();
            std::vector<std::vector<int>> ways(rows, std::vector<int>(columns, 0));
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    if (obstacleGrid[i][j] == 1)
                        ways[i][j] = 0;
                    else if ((i == 0) && (j == 0))
                        ways[i][j] = 1;
                    else if (i == 0)
                        ways[i][j] = ways[i][j - 1];
                    else if (j == 0)
                        ways[i][j] = ways[i - 1][j];
                    else
                        ways[i][j] = ways[i - 1][j] + ways[i][j - 1];
                }
            }
            return ways[rows - 1][columns - 1];
    

  • 1
    Z

    Me too, I've tested other solutions posted here, most got RE as well.
    I think there's something wrong with the system?


  • 0
    F

    I've been experiencing the same issue since yesterday. I tried adding a few printf statements in the middle and found that some led to RTE while others did not.


Log in to reply
 

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