Suppose an array sorted in ascending order 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.
Subscribe to see which companies asked this question.
两种情况,一种第一个比最后一个小,直接返回第一个。另一种移位了,最小的在中间,折半和第一个元素比较。
新闻热点
疑难解答