436. Find Minimum in Rotated Sorted Array

EasyBinary SearchArrayBinary Search

Given a sorted array of distinct integers that has been rotated between 1 and n times, return the minimum element. Solve in O(log n).

Input: A rotated sorted array of distinct integers.

Output: The minimum element in the array.

Examples

Example 1
Input: [3,4,5,1,2]
Output: 1
Explanation: Minimum is 1.
Example 2
Input: [4,5,6,7,0,1,2]
Output: 0
Explanation: Minimum is 0.
Example 3
Input: [11,13,15,17]
Output: 11
Explanation: Not rotated; minimum is the first element.

Constraints

Asked by

MicrosoftAmazonFlipkartMetaInfosysGoogle
Solve this problem in the editor →