摘要:        
https://leetcode.cn/problems/search-insert-position/ 简单二分,这里可以判断return,相当于剪枝 这里的写法最后更新后的l或r一定可以使得nums[l] 或者nums[r]>=target 所以退出循环最后的l或r就是第一个大于等于target    阅读全文
posted @ 2023-04-19 20:13
风乐
阅读(25)
评论(0)
推荐(0)
        
            
        
        
摘要:        
https://leetcode.cn/problems/binary-search/ 简单二分 class Solution { public: int search(vector<int>& nums, int target) { int l=0,r=nums.size()-1; while(l    阅读全文
posted @ 2023-04-19 19:59
风乐
阅读(17)
评论(0)
推荐(0)
        

浙公网安备 33010602011771号