public class Erfenchazhao {
public int search(int [] nums ,int target){
if(target <nums[0] || target> nums[nums.length-1]){
return -1;
}
int left = 0, right = nums.length-1;
while (left<=right){
int mid = left+ (right-left)/2;
if(nums[mid]<target){
left = mid+1;
}else if(nums[mid]>target ){
right = mid-1;
}else {
return mid;
}
}
return -1;
}
04-10
1854
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-20
534
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-20
414
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-24