Skip to content

Commit

Permalink
Merge branch 'master' of github.com:youngyangyang04/leetcode-master
Browse files Browse the repository at this point in the history
  • Loading branch information
youngyangyang04 committed Nov 13, 2021
2 parents 0c4aed8 + e6ab5a4 commit 7c9109d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions problems/0063.不同路径II.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,14 @@ class Solution {
public int uniquePathsWithObstacles(int[][] obstacleGrid) {
int n = obstacleGrid.length, m = obstacleGrid[0].length;
int[][] dp = new int[n][m];
dp[0][0] = 1 - obstacleGrid[0][0];
for (int i = 1; i < m; i++) {
if (obstacleGrid[0][i] == 0 && dp[0][i - 1] == 1) {
dp[0][i] = 1;
}
for (int i = 0; i < m; i++) {
if (obstacleGrid[0][i] == 1) break; //一旦遇到障碍,后续都到不了
dp[0][i] = 1;
}
for (int i = 1; i < n; i++) {
if (obstacleGrid[i][0] == 0 && dp[i - 1][0] == 1) {
dp[i][0] = 1;
}
for (int i = 0; i < n; i++) {
if (obstacleGrid[i][0] == 1) break; ////一旦遇到障碍,后续都到不了
dp[i][0] = 1;
}
for (int i = 1; i < n; i++) {
for (int j = 1; j < m; j++) {
Expand Down

0 comments on commit 7c9109d

Please sign in to comment.