uacs2024

导航

上一页 1 2 3 4 5 6 7 8 ··· 24 下一页

2025年3月12日 #

leetcode 918. 环形子数组的最大和

摘要: 918. 环形子数组的最大和 做不出来,直接看题解 灵神题解: class Solution { public: int maxSubarraySumCircular(vector<int>& nums) { int sum = accumulate(nums.begin(),nums.end(), 阅读全文

posted @ 2025-03-12 12:08 ᶜʸᵃⁿ 阅读(5) 评论(0) 推荐(0)

2025年3月11日 #

leetcode152. 乘积最大子数组

摘要: 152. 乘积最大子数组 没做出来,直接看题解 灵神题解: class Solution { public: int maxProduct(vector<int>& nums) { int n = nums.size(); vector<int> fMin(n);//右端点下标为 i 的子数组的最小 阅读全文

posted @ 2025-03-11 22:00 ᶜʸᵃⁿ 阅读(8) 评论(0) 推荐(0)

2024年12月30日 #

leetcode 1191. K 次串联后最大子数组之和 未解决

摘要: 1191. K 次串联后最大子数组之和 很蠢但能通过的方法:k >= 3时,算三次res。如果res2 - res2 == res3 - res2,说明为等差数列。如果res2 - res2 != res3 - res2,说明循环多次的结果都是一样的。 class Solution { public 阅读全文

posted @ 2024-12-30 21:44 ᶜʸᵃⁿ 阅读(11) 评论(0) 推荐(0)

leetcode 1749. 任意子数组和的绝对值的最大值

摘要: 1749. 任意子数组和的绝对值的最大值 没做出来🤡 法一:动态规划 class Solution { public: int maxAbsoluteSum(vector<int>& nums) { int res = 0; // 初始化以当前元素为结尾的子数组的最大和f_max为0 int f_ 阅读全文

posted @ 2024-12-30 18:21 ᶜʸᵃⁿ 阅读(24) 评论(0) 推荐(0)

leetcode 2606. 找到最大开销的子字符串

摘要: 2606. 找到最大开销的子字符串 class Solution { public: int maximumCostSubstring(string s, string chars, vector<int>& vals) { int size = s.size(); vector<int> dp(s 阅读全文

posted @ 2024-12-30 16:02 ᶜʸᵃⁿ 阅读(7) 评论(0) 推荐(0)

leetcode 213. 打家劫舍 II

摘要: 213. 打家劫舍 II 与 198. 打家劫舍 相比,多了首和尾不能同时偷的条件 但是没写出来🤡 看了题解,可以比较 不偷首 和 不偷尾 ,哪个大就是最终答案 class Solution { public: int rob2(vector<int>& nums,int left,int rig 阅读全文

posted @ 2024-12-30 15:11 ᶜʸᵃⁿ 阅读(7) 评论(0) 推荐(0)

leetcode 3186. 施咒的最大总伤害

摘要: 3186. 施咒的最大总伤害 这道题相比 740. 删除并获得点数 ,区别是这道题的元素值可以特别大,所以就不能开大数组。 没做出来🤡 法一:记忆化搜索 class Solution { public: //定义 dfs(i) 表示从 a[0] 到 a[i] 中选择,可以得到的伤害值之和的最大值。 阅读全文

posted @ 2024-12-30 14:27 ᶜʸᵃⁿ 阅读(47) 评论(0) 推荐(0)

2024年12月29日 #

leetcode 2320. 统计放置房子的方式数

摘要: 2320. 统计放置房子的方式数 class Solution { public: const int MOD = 1'000'000'007; int countHousePlacements(int n) { if(n == 1) return 4; vector<long> dpZero(n+ 阅读全文

posted @ 2024-12-29 15:48 ᶜʸᵃⁿ 阅读(13) 评论(0) 推荐(0)

leetcode 740. 删除并获得点数

摘要: 740. 删除并获得点数 凭着感觉,莫名其妙迷迷糊糊地就通过了,自己也不知道怎么就过了,以下是题解的评论 // 每个位置上的数字是可以在两种前结果之上进行选择的: // 1.如果你不删除当前位置的数字,那么你得到就是前一个数字的位置的最优结果。 // 2.如果你觉得当前的位置数字i需要被删,那么你就 阅读全文

posted @ 2024-12-29 14:32 ᶜʸᵃⁿ 阅读(32) 评论(0) 推荐(0)

leetcode 2266. 统计打字方案数

摘要: 2266. 统计打字方案数 题目挺简单的,就是溢出、取余特别令人抓狂 class Solution { public: const int MOD = 1'000'000'007; int count(const int &choices,const int &num){ if(num <= 2) 阅读全文

posted @ 2024-12-29 13:59 ᶜʸᵃⁿ 阅读(20) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 ··· 24 下一页