标签:
1,二分:
public static int binarySearch(int[] nums, int target) { if(nums == null || nums.length == 0) { return -1; } int start = 0; int end = nums.length - 1; while (start <= end){ int mid = start + (end - start) / 2; if (nums[mid] == target){ return mid; } else if (nums[mid] < target) { start = mid + 1; } else { end = mid - 1; } } return -1; }
标签:
原文地址:http://www.cnblogs.com/yueyebigdata/p/5126333.html