/* * 154. Find Minimum in Rotated Sorted Array II * 2016-6-1 by Mingyang * 只用比end,当中间和上面相等end就-- */ //这里笔者仅仅在I的基础上改动了两笔就通过了,所以这个是非常棒的 public int findMin1(int[] nums) { int start = 0; int end = nums.length - 1; int mid = 0; while(start < end) { mid = start + (end - start) / 2; if (nums[mid] > nums[end]) { start = mid + 1; } else if (nums[mid] < nums[end]) { end = mid; } else { // when num[mid] and num[hi] are same end--; } } return nums[start]; }