LeetCode-35-搜索插入位置-C语言

int searchInsert(int* arr, int len, int target){ int start = 0; int end = len-1; int min ; while(start < end){ min = start + (end - start)/2; if(arr[min] > target){ end = min - 1; }else if(arr[min] < target){ start = min + 1; }else{ return min; } }if(arr[start] < target) return start+1; return start; }

    推荐阅读