An array that was originally sorted in ascending order has been rotated at some unknown pivot, and the array may contain duplicate values. After the rotation, find the smallest element in the array.
The presence of duplicates is what makes this variant harder: when the middle value ties with the boundary value, you cannot tell which half holds the minimum, so the search must degrade gracefully in those ambiguous cases.
Example 1
Input: nums = [4, 5, 6, 6, 1, 2, 3]
Output: 1
The array was rotated so that the ascending run wraps around; the smallest value sitting at the rotation point is 1.
Example 2
Input: nums = [3, 3, 1, 3, 3]
Output: 1
Duplicates surround the pivot, but narrowing the window carefully still isolates the minimum value of 1.
Constraints
1 <= nums.length <= 5 * 10^4-10^4 <= nums[i] <= 10^4nums is a rotation of an array sorted in ascending ordernums may contain duplicate valuesSee the step-by-step animation, the intuition, and clean code in every language — free, no credit card.
FDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.
750+ engineers trained · frontend, backend, AWS & AI