题目

class Solution {
public:
    int searchInsert(vector<int>& nums, int target) {
        
        int start = 0;
        int end=nums.size()-1;
        
        while(start<=end)
        {
            int mid = (start+end)/2;
            
            if(target<=nums[mid])
            {
                end =mid-1;
            }
            else if(target > nums[mid])
            {
                start=mid+1;
            }
        }
        
        return start;
        
    }
};

相关文章:

  • 2021-09-29
  • 2021-11-08
  • 2022-03-06
  • 2022-12-23
  • 2021-10-18
  • 2021-07-28
猜你喜欢
  • 2022-01-03
  • 2021-07-12
  • 2021-08-12
  • 2021-08-09
  • 2021-07-12
  • 2021-09-27
  • 2021-09-07
  • 2021-09-21
相关资源
相似解决方案