Find Minimum in Rotated Sorted Array II

Hard

Description

Given a rotated sorted array with possible duplicates, find the minimum element. The array was originally sorted in ascending order.

Examples

Input:nums = [2,2,2,0,1]
Output:0
Explanation:

Min is 0.

Input:nums = [4,5,6,7,0,1,1,4]
Output:0
Explanation:

The rotated sorted array with duplicates has minimum element 0.

Input:nums = [3,3,3,3]
Output:3
Explanation:

All elements are identical, so the minimum is that repeated value.

Constraints

  • 1 ≤ nums.length ≤ 5000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!