A sorted array of distinct integers has been rotated at an unknown pivot (e.g. [0,1,2,4,5,6,7] becomes [4,5,6,7,0,1,2]). Given the rotated array nums, return its minimum element in O(log n).
Compare the middle to the rightmost element: if nums[mid] > nums[right], the minimum is somewhere to the right of mid; otherwise it's at mid or to its left — same rotated-array shape as Search in Rotated Sorted Array, now hunting the pivot itself.
Example
Input: nums = [3, 4, 5, 1, 2]
Output: 1