1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// @Title: 寻找旋转排序数组中的最小值 (Find Minimum in Rotated Sorted Array)
// @Author: 15816537946@163.com
// @Date: 2020-06-25 07:15:36
// @Runtime: 0 ms
// @Memory: 2.5 MB
/*
func findMin(nums []int) int {
	lo, hi := 0, len(nums)-1
	for lo < hi {
		mid := lo+(hi-lo)/2
		if nums[mid] <= nums[hi] {
			hi = mid
		} else {
			lo  =mid+1
		}
	}
	
	return nums[lo]
}
*/
func findMin(nums []int) int {

	lo, hi := 0, len(nums)-1
	for lo < hi {
		mid := lo + (hi-lo)/2
		if nums[mid] <= nums[hi] {
			hi = mid
		} else {
			lo = mid + 1
		}
	}

	return nums[lo]
}