feat: 2025-10-31打卡

This commit is contained in:
wu xiangkai
2025-10-31 10:00:38 +08:00
parent 71664a10cc
commit 5a9ae36d6b
4 changed files with 124 additions and 21 deletions

34
63.unique-paths-ii.java Normal file
View File

@@ -0,0 +1,34 @@
/*
* @lc app=leetcode id=63 lang=java
*
* [63] Unique Paths II
*/
// @lc code=start
class Solution {
public int uniquePathsWithObstacles(int[][] obstacleGrid) {
int[][] dp = new int[obstacleGrid.length][obstacleGrid[0].length];
for(int i=0;i<dp.length;i++) {
for(int j=0;j<dp[0].length;j++) {
dp[i][j] = 0;
}
}
dp[0][0] = obstacleGrid[0][0]==1?0:1;
for(int i = 0; i<dp.length; i++) {
for(int j=0; j<dp[0].length; j++) {
if(obstacleGrid[i][j] == 1) {
continue;
}
if(i-1>=0) {
dp[i][j] += dp[i-1][j];
}
if(j-1>=0) {
dp[i][j] += dp[i][j-1];
}
}
}
return dp[dp.length-1][dp[0].length-1];
}
}
// @lc code=end