Maximum in a Rotated Sorted Array
Problem statement
A strictly increasing array of distinct integers was rotated at an unknown pivot. Return its maximum value in logarithmic time.
Function
findMaximumInRotatedArray(nums: int[]) → intExamples
Example 1
nums = [4,5,6,1,2,3]return = 6The rotation pivot follows the maximum value six.
Example 2
nums = [10,20,30,40]return = 40An unrotated array has its maximum at the final index.
Constraints
1 <= nums.length <= 200000nums contains distinct signed 32-bit integersnums is an ascending array rotated zero or more positions