479. Find Minimum in Rotated Sorted Array II (Duplicates)

MediumBinary SearchBinary SearchArray

Given an array that was sorted in ascending order and then rotated, possibly containing duplicates, return the minimum element. Input: an array of integers.

Input: An array of integers.

Output: Integer — the minimum element.

Examples

Example 1
Input: [2,2,2,0,1]
Output: 0
Explanation: Minimum is 0.
Example 2
Input: [1,3,5]
Output: 1
Explanation: Not rotated; min is 1.
Example 3
Input: [3,1,3]
Output: 1
Explanation: Minimum is 1.

Constraints

Asked by

MicrosoftGoogleAmazonMeta
Solve this problem in the editor →