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.
兩種情況,一種第一個比最后一個小,直接返回第一個。另一種移位了,最小的在中間,折半和第一個元素比較。
新聞熱點
疑難解答