79. Find Minimum in Rotated Sorted Array
mediumAsked at PlaidFind the minimum element in a rotated sorted array. Plaid asks this because finding the rotation pivot (e.g., the day a circular billing window restarts) is the same primitive.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Plaid loops.
- Glassdoor (2025)— Plaid SWE II OA.
- LeetCode Discuss (2026)— Plaid rotation-pivot finder.
Problem
Suppose an array of length n sorted in ascending order is rotated between 1 and n times. Given the sorted rotated array nums of unique elements, return the minimum element of this array. You must write an algorithm that runs in O(log n) time.
Constraints
n == nums.length1 <= n <= 5000-5000 <= nums[i] <= 5000All the integers of nums are unique.nums is sorted and rotated between 1 and n times.
Examples
Example 1
nums = [3,4,5,1,2]1Example 2
nums = [4,5,6,7,0,1,2]0Example 3
nums = [11,13,15,17]11Approaches
1. Linear scan
Walk and track min.
- Time
- O(n)
- Space
- O(1)
function findMin(nums) { return Math.min(...nums); }Tradeoff: Misses the O(log n) requirement.
2. Binary search for the pivot
Compare nums[mid] to nums[hi]. If nums[mid] > nums[hi], pivot is to the right of mid. Else, mid is in the same sorted half as hi, so pivot is at mid or to the left.
- Time
- O(log n)
- Space
- O(1)
function findMin(nums) {
let lo = 0, hi = nums.length - 1;
while (lo < hi) {
const mid = (lo + hi) >> 1;
if (nums[mid] > nums[hi]) lo = mid + 1;
else hi = mid;
}
return nums[lo];
}Tradeoff: Logarithmic. Comparing to nums[hi] (not nums[lo]) is the standard convention; comparing to nums[lo] requires an extra check for the un-rotated case.
Plaid-specific tips
Plaid grades this on whether you compare to nums[hi]. Bonus signal: walk through the un-rotated case — if no rotation, nums is fully sorted and nums[mid] <= nums[hi] always, so hi keeps shrinking and we land at index 0. Connect to billing-cycle pivots where the 'minimum' is the start of the current cycle.
Common mistakes
- Comparing to nums[lo] — fails on un-rotated arrays without extra handling.
- Using lo <= hi as the loop condition — leads to off-by-one because hi = mid (not mid - 1).
- Forgetting that the array might not be rotated at all.
Follow-up questions
An interviewer at Plaid may pivot to one of these next:
- With duplicates (LC 154) — O(n) worst case.
- Find the rotation count.
- Search for a target after finding the pivot (LC 33).
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why compare to nums[hi]?
It captures both rotated and un-rotated cases in one comparison. Comparing to nums[lo] would need a separate check for the un-rotated case.
Why hi = mid (not mid - 1)?
Because mid itself could be the minimum. Setting hi = mid keeps it as a candidate; lo = mid + 1 only when we've proven mid is not the answer.
Practice these live with InterviewChamp.AI
Drill Find Minimum in Rotated Sorted Array and other Plaid interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →