uacs2024

导航

2024年12月20日 #

leetcode 2576. 求出最多标记下标

摘要: 2576. 求出最多标记下标 题解: 这道题从左往右扫描和从右往左扫描都是错的。 比如 : 1 1 1 1 2 2 2 4 ,从右往左,如果将倒数的2 和 4 匹配了,那么剩下的都不能匹配了。但实际上全部都能匹配。 比如: 1 2 2 2 5 5 5 5,从左往右,如果将 1 和 2 匹配,两个 2 阅读全文

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

leetcode 2592. 最大化数组的伟大值

摘要: 2592. 最大化数组的伟大值 法一:排序 丑陋的代码 class Solution { public: int maximizeGreatness(vector<int>& nums) { sort(nums.begin(),nums.end()); int size = nums.size(), 阅读全文

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

leetcode 8. 字符串转换整数 (atoi)

摘要: 8. 字符串转换整数 (atoi) 丑陋的代码 class Solution { public: int myAtoi(string s) { int i = 0,size = s.size(); bool isPositive = true; long res = 0; while(s[i] == 阅读全文

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