A sorted array has been rotated between 1 and n times. For example, [0,1,2,4,5,6,7] rotated 4 times becomes [4,5,6,7,0,1,2].
Find the minimum element. You must write an O(log n) algorithm.
Binary search trick: compare nums[mid] with nums[right]. If mid > right, the minimum is in the right half. Otherwise, it's in the left half (including mid).
find_min([3,4,5,1,2])
1
find_min([4,5,6,7,0,1,2])
0