The Find Minimum in Rotated Sorted Array interview question is a classic search optimization task. You are given an array that was originally sorted in ascending order but then rotated at an unknown pivot (e.g., [4, 5, 6, 7, 0, 1, 2]). Your goal is to find the minimum element in time. This Find Minimum in Rotated Sorted Array coding problem tests your ability to adapt standard search algorithms to "broken" sorted properties.
This is a standard question at almost every major tech company, including Apple, Microsoft, and Amazon. It evaluates your understanding of Binary Search interview patterns. Specifically, it checks if you can identify which half of an array is still sorted and use that information to discard half of the search space, even when the global sorted property is violated.
The problem is solved using a modified Binary Search.
left = 0, right = n - 1.nums[mid] with nums[right].nums[mid] > nums[right], the minimum must be in the right half (because the "drop" occurred there). Move left = mid + 1.nums[mid] < nums[right], the right half is sorted normally, so the minimum is either at mid or to its left. Move right = mid.left == right, you've found the pivot point, which is the minimum.Array: [4, 5, 6, 7, 0, 1, 2]
left=0 (4), right=6 (2), mid=3 (7).left to index 4. Array is now [0, 1, 2].left=4 (0), right=6 (2), mid=5 (1).right to index 5. Array is now [0, 1].left=4 (0), right=5 (1), mid=4 (0).right to index 4.left == right. Result: 0.nums[0] is the minimum.left <= right which can lead to infinite loops if not careful with the mid update.Always look for the sorted property. If an array is "mostly" sorted, Binary Search is usually the answer. Practice variations of this, such as searching for a target in a rotated array, to strengthen your pointer logic.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Find Peak Element | Medium | Solve | |
| Search in Rotated Sorted Array II | Medium | Solve | |
| Find First and Last Position of Element in Sorted Array | Medium | Solve | |
| Search in Rotated Sorted Array | Medium | Solve | |
| Koko Eating Bananas | Medium | Solve |