FrontendX
Find Minimum in Rotated Sorted Array
medium
Description
AI Assistance
Solution
Test Cases
Test Result
Submissions
Canvas
Find Minimum in
Rotated Sorted Array
Return the minimum value in a rotated sorted array with unique values.
Examples
Example 1
Input:
[3,4,5,1,2]
Output:
1
Example 2
Input:
[4,5,6,7,0,1,2]
Output:
0
Hints
Hint 1
Compare `nums[mid]` with `nums[left]` to determine which half is sorted and adjust the search range accordingly.
Hint 2
If `nums[mid] > nums[right]`, the minimum must be in the right half; otherwise, it's in the left half (including `mid`).
Hint 3
If the array is not rotated (i.e., `nums[left] <= nums[right]`), return `nums[left]` directly.
Related Problems
two-sum
Find Minimum in Rotated Sorted Array
Return the minimum value in a rotated sorted array with unique values.