Find Minimum in Rotated Sorted Array
Given a rotated sorted array of unique integers Return the minimum element in O(log n) time Example: nums = [3,4,5,1,2] => 1 The array was originally [1,2,3,4,5] and rotated 3 times
This one is really a boundary-finding problem, even if it doesn't look like it at first. Interviewers love it because it reveals your boundary precision and your edge-case discipline. The trap is boundary drift—one wrong low/high update can loop forever or skip the answer.
Examples
You write
find_min(nums: List[int])
Example 1
- Input
- nums = [3,4,5,1,2]
- returns
- 1
Example 2
- Input
- nums = [4,5,6,7,0,1,2]
- returns
- 0
The pattern behind it
Arrays & Hashing
I reach for it when
- You catch yourself scanning the array again for every element.
- The problem asks about duplicates, pairs, counts or groups.
Say this before you type. Say what the key is and what the value remembers, before you write the loop.
All 127 Arrays & Hashing problemsBinary Search
I reach for it when
- The input is sorted, or sorted and then rotated.
- You want a boundary: the first or last place something is true.
Say this before you type. Say the yes-or-no question, and which side each answer throws away.
All 19 Binary Search problems
Meet Coco
Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit. The editor and Run stay open without an account. Anyone can open the editor and run their code.
Each locked part opens in the editor once the part before it passes.