L159 Find Minimum in Rotated Sorted Array
Last updated
Last updated
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e.,0 1 2 4 5 6 7
might become4 5 6 7 0 1 2
).
Find the minimum element.
You may assume no duplicate exists in the array.
Example
Given[4, 5, 6, 7, 0, 1, 2]
return0
还是2分模板,这个没重复。还是找有序的一半,然后判断下标移动。想像一条斜线砍一半。竖线表示mid的位置,如果砍在左边,min在右边,如果砍在右边,min在左边。