题目:牛客网
解题思路:
二分查找
public class Solution {
public int searchInsert(int[] A, int target) {
int low = 0;
int high = A.length-1;
while(low<=high){
int mid = (low+high)/2;
if(target == A[mid]){
return mid;
}
else if(target < A[mid]){
high =mid-1;
}
else{
low = mid+1;
}
}
return low;
}
}