Minimum in a Rotated Sorted Array
Problem statement
The array nums contains distinct integers. It was sorted in strictly increasing order and then rotated; a full-length rotation may leave it unchanged.
Return the minimum value in the array. Your final algorithm must use O(log n) time, where n = nums.length.
Function
findMin(nums: int[]) → intExamples
Example 1
nums = [3,4,5,1,2]return = 1The increasing lower segment begins at1.
Example 2
nums = [4,5,6,7,0,1,2]return = 0A rotation places0 between7 and1.
Example 3
nums = [11,13,15,17]return = 11A full-length rotation leaves the increasing array unchanged.
Constraints
1 <= nums.length <= 5000.-5000 <= nums[i] <= 5000.- All values are distinct, and
numsis a rotation of a strictly increasing array.