uacs2024

导航

2024年12月13日 #

leetcode 228. 汇总区间

摘要: 228. 汇总区间 class Solution { public: vector<string> summaryRanges(vector<int>& nums) { int size = nums.size(); if(size == 1) return {to_string(nums[0])} 阅读全文

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

leetcode 658. 找到 K 个最接近的元素

摘要: 658. 找到 K 个最接近的元素 法一: class Solution { public: vector<int> findClosestElements(vector<int>& arr, int k, int x) { vector<pair<int,int>> dist; vector<in 阅读全文

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

leetcode 977. 有序数组的平方

摘要: 977. 有序数组的平方 法一:双指针,先找负数与非负数的边界 class Solution { public: vector<int> sortedSquares(vector<int>& nums) { vector<int> res; if(nums[0] >= 0){//全部非负的情况 fo 阅读全文

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