63. Unique Paths II

    xiaoxiao2021-03-26  7

    跟上一题基本一样,,,简单的不得了

    class Solution { public: int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) { int dp[105][105]; int m = obstacleGrid.size(); if(m == 0) return 0; int n = obstacleGrid[0].size(); memset(dp, 0, sizeof(dp)); dp[0][1] = 1; for(int i = 1; i <= m; ++ i) for(int j = 1; j <= n; ++ j) if(obstacleGrid[i - 1][j - 1] == 0) dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; return dp[m][n]; } };
    转载请注明原文地址: https://ju.6miu.com/read-650306.html

    最新回复(0)