Skip to main content

82. Find Minimum in Rotated Sorted Array

mediumAsked at Vercel

Find the minimum in a rotated sorted array. Vercel asks this for the binary-search-on-rotation-point pattern — same shape as locating the pivot in their consistent-hashing ring after a node was repositioned.

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Vercel loops.

  • Glassdoor (2025-Q4)Vercel platform onsite; modified binary search expected.
  • Blind (2026-Q1)Listed in Vercel screen pool.

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.length
  • 1 <= n <= 5000
  • -5000 <= nums[i] <= 5000
  • All the integers of nums are unique.
  • nums is sorted and rotated between 1 and n times.

Examples

Example 1

Input
nums = [3,4,5,1,2]
Output
1

Example 2

Input
nums = [4,5,6,7,0,1,2]
Output
0

Example 3

Input
nums = [11,13,15,17]
Output
11

Approaches

1. Linear scan

Walk and track min.

Time
O(n)
Space
O(1)
function findMin(nums) {
  return Math.min(...nums);
}

Tradeoff: Violates O(log n).

2. Binary search on rotation pivot (optimal)

Compare mid with hi. If mid > hi, min is in right half. Else min is in left half (including mid). Narrow until lo == hi.

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: Compare with hi (not lo) because the rotation pivot is always BETWEEN lo and hi. Comparing with lo fails when the array isn't rotated.

Vercel-specific tips

Vercel grades the compare-with-hi insight. Bonus signal: explaining WHY comparing with lo fails (in an un-rotated array, nums[mid] > nums[lo] but the min is still lo, breaking the invariant). The hi comparison works for all rotations including zero.

Common mistakes

  • Comparing mid with lo — fails for un-rotated arrays.
  • Using lo <= hi — overshoots.
  • Computing mid as `(lo + hi) / 2 | 0` — fine but signal-less.

Follow-up questions

An interviewer at Vercel may pivot to one of these next:

  • Find Minimum in Rotated Sorted Array II (LC 154) — duplicates.
  • Find both min AND max of a rotated array.
  • Search in Rotated Sorted Array (LC 33) — find an arbitrary target.

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why compare with hi, not lo?

The minimum is always at the rotation pivot or at index 0. Comparing with hi: if mid > hi, the pivot must be RIGHT of mid (rotation creates a 'drop'). If mid <= hi, the pivot is LEFT of or at mid. Lo comparison fails when there's no rotation.

When does this fail with duplicates?

When nums[mid] == nums[hi], we can't tell which side has the pivot. LC 154 handles that with a hi-- step, degrading to O(n) worst case.

Practice these live with InterviewChamp.AI

Drill Find Minimum in Rotated Sorted Array and other Vercel interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →