随笔分类 -  LeetCode

摘要:第 387 场周赛 将元素分配到两个数组中 I 解题思路: 暴力比较放置。 代码: class Solution { public: vector<int> resultArray(vector<int>& nums) { vector<int> a, b; int n = nums.size(); 阅读全文
posted @ 2024-03-03 15:28 value0 阅读(11) 评论(0) 推荐(0)
摘要:LeetCode 第 121 场双周赛 大于等于顺序前缀和的最小缺失整数 代码: class Solution { public: int missingInteger(vector<int>& nums) { int n = nums.size(); set<int> s; for(auto x 阅读全文
posted @ 2024-01-18 16:21 value0 阅读(15) 评论(0) 推荐(0)
摘要:前缀和变形 + 哈希表 统计趣味子数组的数目 解题思路: 设 \[s_i = \sum_{i = 1} ^ n{nums[i] \% module == k} \]题目求满足$s_r - s_{l-1} \equiv k \pmod {module} $的子数组的个数。 公式转换: \[\begin 阅读全文
posted @ 2023-09-13 00:28 value0 阅读(30) 评论(0) 推荐(0)