image.png

解题思路

二分查找

  1. public int findMin(int[] nums) {
  2. int start = 0;
  3. int end = nums.length-1;
  4. int mid = 0;
  5. while(start<=end){
  6. mid = (start+end)/2;
  7. if(nums[start]<=nums[end])
  8. return nums[start];
  9. if(nums[start]>nums[mid])
  10. end = mid;
  11. else
  12. start = mid+1;
  13. }
  14. return -1;
  15. }