摘要:
518 零钱兑换II class Solution { public: int change(int amount, vector& coins) { vector<int> dp(5001, 0); dp[0] = 1; for(int i = 0; i < coins.size(); ++i) 阅读全文
posted @ 2024-10-13 11:02
ikun1111
阅读(11)
评论(0)
推荐(0)
摘要:
1049 最后一块石头的重量II class Solution { public: int lastStoneWeightII(vector& stones) { int sum = 0; for(int &it : stones) { sum += it; } int target = sum / 阅读全文
posted @ 2024-10-13 10:53
ikun1111
阅读(11)
评论(0)
推荐(0)
摘要:
416 分割等和子集 class Solution { public: bool canPartition(vector& nums) { int sum = 0; for(int &it : nums) { sum += it; } if(sum % 2 == 1) { return false; 阅读全文
posted @ 2024-10-13 10:46
ikun1111
阅读(14)
评论(0)
推荐(0)
摘要:
62 不同路径 class Solution { public: int uniquePaths(int m, int n) { vector<vector> dp(m, vector(n, 0)); if(m <= 1) { return m; } if(n <= 1) { return n; } 阅读全文
posted @ 2024-10-13 10:43
ikun1111
阅读(14)
评论(0)
推荐(0)
摘要:
509 斐波拉契数 class Solution { public: int fib(int n) { if(n <= 1) { return n; } vector dp(n+1); dp[0] = 0; dp[1] = 1; for(int i = 2; i <= n; ++i) { dp[i] 阅读全文
posted @ 2024-10-13 10:38
ikun1111
阅读(10)
评论(0)
推荐(0)

浙公网安备 33010602011771号