2022年12月29日
摘要: 977 有序数组的平方 class Solution { public: vector<int> sortedSquares(vector<int>& nums) { vector<int> result(nums.size(),0); int k = nums.size()-1; for (int 阅读全文
posted @ 2022-12-29 22:08 有什么大不了就散 阅读(91) 评论(0) 推荐(0)
  2022年12月28日
摘要: 704 二分查找 一:左闭右闭 1.因为包含右边的边界,所以right=nums.size-1 2.区间允许左边等于右边,所以在写while循环时,条件记为 “>=“ 3.做完比较后,middle的值不应该包含在区间内 4. 创建一维vector vector<int> nums; //不指定长度v 阅读全文
posted @ 2022-12-28 15:26 有什么大不了就散 阅读(79) 评论(0) 推荐(0)