lichao_normal

导航

Search Insert Position

int searchInsert(int* nums, int numsSize, int target) {
    int low=0;
    if(numsSize<=0)return 0;
    int high=numsSize-1;
    int mid;
    while(low<=high){
        mid=(low+high)/2;
        if(nums[mid]>=target)high=mid-1;
        else low=mid+1;
    }
    return low;
}
View Code

 

posted on 2016-12-09 20:37  lichao_normal  阅读(68)  评论(0编辑  收藏  举报