Skip to interview prep
Apexed
Problem list100 / 125

100. Minimum in a Rotated Sorted Array

MediumSearching

An ascending array of distinct numbers has been rotated at an unknown point (for example [0, 1, 2, 4, 5] might become [4, 5, 0, 1, 2]). Return its smallest element in O(log n) time.

Example 1

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

Constraints

  • 1 ≤ nums.length ≤ 5000
  • Values are distinct

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 5 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Minimum in a Rotated Sorted Array — coding interview practice — Apexed