uacs2024

导航

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 24 下一页

2024年12月3日 #

leetcode 2653. 滑动子数组的美丽值

摘要: 2653. 滑动子数组的美丽值 暴力超时解,纯批判性展示🤡 class Solution { public: vector<int> getSubarrayBeauty(vector<int>& nums, int k, int x) { int size = nums.size(); if(si 阅读全文

posted @ 2024-12-03 21:28 ᶜʸᵃⁿ 阅读(17) 评论(0) 推荐(0)

leetcode 1297. 子串的最大出现次数 未解决

摘要: 1297. 子串的最大出现次数 暴力解,超时🤡 class Solution { public: int maxFreq(string s, int maxLetters, int minSize, int maxSize) { int size = s.size(), maxRes = 0; u 阅读全文

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

2024年12月2日 #

leetcode 1652. 拆炸弹 未解决

摘要: 1652. 拆炸弹 原本是简单题,但是k < 0的情况由于选用的方法不好,浪费太多时间了。代码也有很多冗余 class Solution { public: vector<int> decrypt(vector<int>& code, int k) { int size = code.size(); 阅读全文

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

leetcode 1423. 可获得的最大点数

摘要: 1423. 可获得的最大点数 首先,前 k 个数和后 k 个数 的 较大者并不是正确答案,比如 100 40 17 9 73 75,正确解是248。 其次,想到了前或者后拿了一个数之后,就是求剩下序列拿k-1个数,可以转换成子问题,所以想到了递归。但是k比较大的时候就超时了: class Solut 阅读全文

posted @ 2024-12-02 18:28 ᶜʸᵃⁿ 阅读(11) 评论(0) 推荐(0)

leetcode 2841. 几乎唯一子数组的最大和 2461. 长度为 K 子数组中的最大和

摘要: 两道题本质是一样的,所以放一起了 2841. 几乎唯一子数组的最大和 使用unordered_map;unordered_multiset可能也可以,但是不如前者方便 class Solution { public: long long maxSum(vector<int>& nums, int m 阅读全文

posted @ 2024-12-02 15:50 ᶜʸᵃⁿ 阅读(31) 评论(0) 推荐(0)

leetcode 1461. 检查一个字符串是否包含所有长度为 K 的二进制子串

摘要: 1461. 检查一个字符串是否包含所有长度为 K 的二进制子串 使用unordered_set ,通过集合数量来判断 法一:将二进制数转化为十进制数,放到集合中。此法用时139ms,内存48.2MB class Solution { public: bool hasAllCodes(string s 阅读全文

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

2024年12月1日 #

leetcode 1456. 定长子串中元音的最大数目

摘要: 1456. 定长子串中元音的最大数目 法一:借助队列 class Solution { public: int maxVowels(string s, int k) { int size = s.size(), resMax = 0; queue<bool> qVowel; for(int i = 阅读全文

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

2024年11月30日 #

leetcode 56. 合并区间

摘要: 56. 合并区间 一开始的想法时,用一个nums数组给各个区间[ startI , rightI ] 自增 1 ,但是这是错误的。 当遇到 [1 , 2 ] [ 3 , 4 ] , [1 , 2 ] [ 0 , 0 ] 等情况会变得很难分辨。 这道题的intervals里面各个 start 和 en 阅读全文

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

leetcode 191. 位1的个数

摘要: 191. 位1的个数 给定一个正整数 n,编写一个函数,获取一个正整数的二进制形式并返回其二进制表达式中设置位的个数。1 <= n <= 2^32-1 法一:暴力解: class Solution { public: int hammingWeight(uint32_t n) { int count 阅读全文

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

leetcode 2289. 使数组按非递减顺序排列 未解决

摘要: leetcode 2289. 使数组按非递减顺序排列 这道题远没有想象中的简单,如果用暴力常规方法,数据量大的情况下会超时 暴力解1: class Solution { public: int totalSteps(vector<int>& nums) { int size = nums.size( 阅读全文

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

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 24 下一页