标签:
1 public int binarySearch(int[] nums, int target) { 2 int low = 0; 3 int high = nums.length; 4 while (low <= high) { 5 int mid = (low + high) / 2; 6 if (nums[mid] == target) 7 return mid; 8 else if (nums[mid] < target) 9 low = mid + 1; 10 else 11 high = mid - 1; 12 } 13 return -1; 14 }
标签:
原文地址:http://www.cnblogs.com/acode/p/5796280.html