Find Minimum in Rotated Sorted Array
Problem statement
You are given an array nums containing distinct integers. Before it is passed to your function, the array was sorted in strictly increasing order and then rotated at an unknown pivot. It may also have been rotated by its full length, leaving it in increasing order.
Return the minimum value in nums.
Your algorithm must run in O(log n) time.
Function
findMinimumInRotatedArray(nums: int[]) → intExamples
Example 1
nums = [3,4,5,1,2]return = 1The increasing array [1,2,3,4,5] was rotated, and its minimum value is 1.
Example 2
nums = [4,5,6,7,0,1,2]return = 0The rotation point lies between 7 and 0, so the minimum is 0.
Example 3
nums = [11,13,15,17]return = 11A full-length rotation leaves the array in increasing order, so its first value is the minimum.
Constraints
1 <= nums.length <= 5000.-5000 <= nums[i] <= 5000.- All values in
numsare distinct. numsis a rotation of a strictly increasing array.