Given a sorted array of unique elements that has been rotated at some unknown pivot, find the minimum element.
For example, given nums = [3, 4, 5, 1, 2], the output is 1. The original sorted array [1, 2, 3, 4, 5] was rotated at the pivot between 5 and 1.
Explain your approach, how binary search applies to finding the minimum (not searching for a specific target), and analyze complexity.
How to approach it
- Hint 1
The minimum element is the point where the sorted order breaks -- it is smaller than its predecessor.
- Hint 2
Compare the middle element with the rightmost element to determine which half contains the minimum.
- Hint 3
If nums[mid] > nums[right], the minimum is in the right half (the rotation point is there). Otherwise, it is in the left half including mid.
Ready to answer it out loud?
Record your answer in 1:30 and Preptile scores it 1–10 with specifics — what landed, what you skipped, and what to say next time.
Practising needs an invite code. Join the waitlist and we’ll send you one.