154. Find Minimum in Rotated Sorted Array II
Practice Find Minimum in Rotated Sorted Array II for free on NudgeCode: Hard, Binary Search pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
A sorted (non-decreasing) array was rotated between 1 and n times; for example [0,1,4,4,5,6,7] might become [4,5,6,7,0,1,4]. Unlike problem 153, the array may contain duplicates. Return the minimum element, using as few operations as possible.
Example
nums = [1,3,5] -> 1
nums = [2,2,2,0,1] -> 0
Constraints
- 1 <= n <= 5000
- -5000 <= nums[i] <= 5000
- nums is a rotated non-decreasing array
- Follow-up: how do duplicates affect the running time?