随笔分类 -  二分

摘要:在排序数组中查找数字 题目链接:https://leetcode-cn.com/problems/zai-pai-xu-shu-zu-zhong-cha-zhao-shu-zi-lcof/ class Solution { public: int search(vector<int>& nums, 阅读全文
posted @ 2020-08-23 15:03 NaughtyCoder 阅读(117) 评论(0) 推荐(0)
摘要:找精确值模板 int l = 0, r = n - 1; while(l <= r) { int mid = l + r >> 1; if(arr[mid] == target) return mid; else if(arr[mid] > target) r = mid - 1; else l = 阅读全文
posted @ 2020-08-22 22:58 NaughtyCoder 阅读(116) 评论(0) 推荐(0)