import java.util.*; public class Solution { public int search (int[] nums, int target) { // 比较与中间点大小进行二分查找 int mid =0; int l = 0; int r = nums.length-1; while(l<=r){ mid = (l+r) /2; if(target<nums[mid]){ r = mid-1; }else if(target>nums[mid]){ l = mid+1; }else{ return mid; } } return -1; } }