Loading...
You are given an integer array nums of unique values that was sorted in ascending order and then rotated between 1 and n times (rotating n times restores the original order). Rotating once moves the last element to the front.
For example, [0, 1, 2, 4, 5, 6, 7] rotated 4 times gives [4, 5, 6, 7, 0, 1, 2].
Return the minimum element of nums.
You must write an algorithm that runs in O(logn) time.
Input: nums = [3, 4, 5, 1, 2]
Output: 1
Explanation: [1, 2, 3, 4, 5] rotated 3 times.
Input: nums = [4, 5, 6, 7, 0, 1, 2]
Output: 0
Input: nums = [11, 13, 15, 17]
Output: 11
Explanation: Rotated 4 times, which restores the original order.
nums.length ≤5000nums[i] ≤5000nums are uniquenums was sorted ascending, then rotated between 1 and n timesClick "Run" to test with sample cases or "Submit" to run all tests.