algorythms
Modified Binary Search
LC #153Medium

Find Minimum in Rotated Sorted Array

Modified Binary Search
AmazonGoogleMetaMicrosoft

Problem

Find the minimum element in a rotated sorted array.

arraybinary-search

Constraints

  • 1 ≤ n ≤ 5000
  • -5000 ≤ nums[i] ≤ 5000
  • All values are unique
  • O(log n) runtime required

Example

Inputnums = [3, 4, 5, 1, 2]
Output1
Why

Rotated at index 3; minimum is 1

Hints — reveal one at a time