Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array [0, 1, 2, 4, 5, 6, 7] might become [4, 5, 6, 7, 0, 1, 2] if rotated 4 times.
Given the rotated sorted array nums of unique elements, return the minimum element of this array.
You must write an algorithm that runs in O(log n) time.
Original: [0, 1, 2, 4, 5, 6, 7]
Rotated: [4, 5, 6, 7, 0, 1, 2]
^
minimum
Input: nums = [3, 4, 5, 1, 2] Output: 1 Explanation: The array was rotated 3 times. The minimum is 1 at index 3.
Input: nums = [4, 5, 6, 7, 0, 1, 2] Output: 0 Explanation: The array was rotated 4 times. The minimum is 0 at index 4.
n == nums.length1 <= n <= 5000-5000 <= nums[i] <= 5000nums are unique.nums is sorted and rotated between 1 and n times.nums = [3, 4, 5, 1, 2]