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

31
62.unique-paths.java Normal file
View File

@@ -0,0 +1,31 @@
/*
* @lc app=leetcode id=62 lang=java
*
* [62] Unique Paths
*/
// @lc code=start
class Solution {
public int uniquePaths(int m, int n) {
int[][] dp = new int[m][n];
for(int i = 0; i<dp.length; i++) {
for(int j=0; j<dp[0].length; j++) {
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for(int i = 0; i<dp.length; i++) {
for(int j=0; j<dp[0].length; j++) {
if(i-1>=0) {
dp[i][j] += dp[i-1][j];
}
if(j-1 >=0) {
dp[i][j] += dp[i][j-1];
}
}
}
return dp[m-1][n-1];
}
}
// @lc code=end