Find Minimum in Rotated Sorted Array

Problem A sorted array of distinct integers was rotated at an unknown pivot. Find the minimum element in O(log n).

Input / Output

  • Input: int array nums (rotated sorted).
  • Output: the minimum value.

Constraints

  • n up to 5000; O(log n) required.

Example

  • [3,4,5,1,2] → 1; [11,13,15,17] → 11 (not rotated).
asked …
LeaderboardSalaryAccount