Leetcode|Leetcode 35. 搜索插入位置

【Leetcode|Leetcode 35. 搜索插入位置】(l,r]找low

class Solution { public: int searchInsert(vector& nums, int target) { vector ans; int l = -1, r = (int)nums.size()-1; while (l < r) { int mid = (l + r+1) >> 1; if (nums[mid] < target) l = mid; else r = mid - 1; } return ++l; } };

    推荐阅读