Problem · Array
Minimum in a Rotated Sorted Array
Learn this problemProblem statement
An array values was originally sorted in strictly increasing order and then rotated at an unknown pivot. The array may also be unrotated.
Return its minimum value. Your algorithm should run in logarithmic time.
Function
findMinimum(values: int[]) → intExamples
Example 1
values = [3,4,5,1,2]return = 1The sorted order was rotated so that 1, the minimum, begins the final increasing segment.
Example 2
values = [4,5,6,7,0,1,2]return = 0The rotation pivot places 0 after 7.
Example 3
values = [11,13,15,17]return = 11The array is unrotated, so its first value is the minimum.
Constraints
1 <= values.length <= 10^5-2^31 <= values[i] <= 2^31 - 1- All values are distinct.
valuesis a rotation of a strictly increasing array.