DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Array

Find Minimum in Rotated Sorted Array

**Problem Statement:** 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. **Hint / Expected Approach:** Binary search pivot detection **Edge Cases to Consider:** - (1) Not rotated (already sorted) - (2) Rotated n–1 times - (3) Duplicates variant

Examples

Example 1
Input: [3,4,5,1,2]
Output: 1
Example 2
Input: [4,5,6,7,0,1,2]
Output: 0
Example 3
Input: [11,13,15,17]
Output: 11

Constraints

  • ▪1 <= nums.length <= 10^4
  • ▪-10^9 <= nums[i] <= 10^9
  • ▪Time complexity should be O(n) or O(n log n)

Watch Out For Edge Cases

  • ▪Not rotated (already sorted)
  • ▪Rotated n–1 times
  • ▪Duplicates variant
Frequently Asked At
GoogleAmazonMicrosoftMetaAdobe