[题] 二分搜索
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
Find the minimum element.
You may assume no duplicate exists in the array.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
Find the minimum element.
You may assume no duplicate exists in the array.
一个有序的无重复数字的整型数组,从某处断开,前后互调。例如
[ 0 1 2 | 4 5 6 7 ] 从 2 和 4 中间断开,前后互调得 [ 4 5 6 7 0 1 2 ]。
现在给你一个这样的数组(原本有序,后被前后互调),要求你快速的找到数组中的最小值。
例如给你 [ 4 5 6 7 0 1 2 ],你应该返回 0
例如给你 [ 1 2 ],你应该返回 1
提示:使用二分法以提高效率