63. Minimum in Rotated Sorted Array
An increasing sorted array has been rotated by moving a prefix to the end. Find its smallest value using the remaining order structure.
Return the value, not its position. The array is nonempty and has distinct values; preserve it and use logarithmic search.
Example 1
Input
[4,5,6,7,0,1,2]
Output
0
Explanation: nums[mid]=7 exceeds right value 2, so the minimum is strictly after mid.
Example 2
Input
[1,2,3]
Output
1
Explanation: An already sorted interval keeps its left side, eventually leaving index 0.
Example 3
Input
[2,3,4,1]
Output
1
Explanation: When mid is larger than the right endpoint, discard through mid; the final candidate is the last index.
Constraints
1 <= nums.length <= 105-231 <= nums[i] <= 231 - 1- nums is a rotation of a strictly increasing array; all values are distinct.
Hints
Hint 1
The minimum must stay in one nonempty closed interval.
Hint 2
Compare nums[mid] to the current nums[right], not to a target.
Hint 3
If mid is higher, move left past it; otherwise retain it with right=mid.
Submissions
Your recent submissions for this problem.
Checking sign-in…
Discussion
Ask a question or share an approach. Posts are public; avoid personal information and mark solution spoilers clearly.
No discussion yet. Start the conversation with a question about this problem.
Checking sign-in…
Run your code to check the sample cases, or submit it to check the full validation suite.
Midpoint comparison finds a late pivot
[2,3,4,1]
1