leetcode(153)寻找旋转排序数组中的最小值
寻找旋转排序数组中的最小值
解题思路:二分法查找
class Solution { public int findMin(int[] nums) { int len = nums.length; int start = 0; int end = len - 1; int middle = 0; if(len == 1){ return nums[0]; } if(nums[start]<nums[end]){ return nums[start]; } while(start<=end){ middle = (start+end)/2; if(nums[middle]>=nums[0]){ start = middle + 1; }else{ end = middle - 1; } } return nums[start]; } }