01 2025 档案

63. 不同路径 II
摘要:https://leetcode.cn/problems/unique-paths-ii/ class Solution { public: int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) { int m = obsta 阅读全文

posted @ 2025-01-26 18:25 TMatrix52 阅读(3) 评论(0) 推荐(0) 编辑

62. 不同路径
摘要:class Solution { public: int uniquePaths(int m, int n) { // 二维dp数组 vector<vector<int> >dp(m, vector<int>(n, 0)); //初始化 for (int j = 0; j<n; j++) { dp[ 阅读全文

posted @ 2025-01-26 17:59 TMatrix52 阅读(2) 评论(0) 推荐(0) 编辑

746. 使用最小花费爬楼梯
摘要:class Solution { public: int minCostClimbingStairs(vector<int>& cost) { // dp[i] 为选择下标为i的台阶向上爬,所需要的最低花费 // dp[i] = min(dp[i-2] + cost[i-2], dp[i-1] + 阅读全文

posted @ 2025-01-25 17:19 TMatrix52 阅读(3) 评论(0) 推荐(0) 编辑

70. 爬楼梯
摘要:class Solution { public: int climbStairs(int n) { // dp[i] 为到达第i个台阶所用的方法 // dp[i] = dp[i-1]+dp[i-2] 两种方法之和 // dp[0] = 0 // dp[1] = 1 // dp[2] = 2 // d 阅读全文

posted @ 2025-01-25 16:22 TMatrix52 阅读(5) 评论(0) 推荐(0) 编辑

509. 斐波那契数
摘要:https://leetcode.cn/problems/fibonacci-number/ // 递归的写法 // class Solution { // public: // int fib(int n) { // if (n==0) { // return 0; // } // if (n== 阅读全文

posted @ 2025-01-25 11:41 TMatrix52 阅读(4) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示