Dashboard
LC #153

Find Minimum in Rotated Sorted Array

Pattern · ?AmazonGoogleMetaMicrosoft

Problem

Find the minimum element in a rotated sorted array.

Constraints

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

Example

Input
nums = [3, 4, 5, 1, 2]
Output
1
Why
Rotated at index 3; minimum is 1

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗