Problem Statement
Find Minimum in Rotated Sorted Array
Start with a list of unique numbers sorted from smallest to largest. Now imagine someone takes a chunk from the front and moves it to the back. That is a rotation. For example, [1,2,3,4,5] rotated becomes something like [3,4,5,1,2]. Your job is to find the smallest number in this rotated list. The numbers are all different, so there is exactly one smallest.
Signals to notice
Brute force first
Linear scan to find where the descent happens. Ignores the sorted structure entirely. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
The key insight
Binary search: compare mid to right. If mid > right, the minimum is in the right half (the rotation break is there). If mid ≤ right, the minimum is in the left half including mid. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
Trace it on nums=[4,5,6,7,0,1,2]
init: left=0, right=6 (search whole array) mid=3, nums[3]=7 > nums[6]=2 -> min in right half, left=4 left=4, right=6, mid=5, nums[5]=1 <= nums[6]=2 -> min in left half incl mid, right=5 left=4, right=5, mid=4, nums[4]=0 <= nums[5]=1 -> right=4 left=4, right=4 -> left<right false, loop ends return nums[4] = 0
What must stay true
The minimum is always at the rotation point — where the sorted order breaks. One half of the array around mid is always fully sorted; the minimum is in the other half. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Shape of the loop
left, right = 0, n-1
while left < right:
mid = (left + right) // 2
if nums[mid] > nums[right]: left = mid + 1 # min is to the right
else: right = mid # min is at mid or left
return nums[left]Pseudocode only — the full worked solution lives in the Solution tab.
Easy way to go wrong
Comparing mid to left instead of right. Comparing to right is cleaner because it directly tells you which half contains the rotation point. The fix is usually to return to the meaning of each move, not just the steps themselves.