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;
}
};
推荐阅读
- 【译】20个更有效地使用谷歌搜索的技巧
- 【Leetcode/Python】001-Two|【Leetcode/Python】001-Two Sum
- leetcode|leetcode 92. 反转链表 II
- 二叉树路径节点关键值和等于目标值(LeetCode--112&LeetCode--113)
- LeetCode算法题-11.|LeetCode算法题-11. 盛最多水的容器(Swift)
- LeetCode(03)Longest|LeetCode(03)Longest Substring Without Repeating Characters
- Leetcode|Leetcode No.198打家劫舍
- locate搜索
- springboot结合redis实现搜索栏热搜功能及文字过滤
- 茶事|茶事 | 单丛里的一泡奇葩