> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/binary-search/154.-find-minimum-in-rotated-sorted-array-ii.md).

# 154. Find Minimum in Rotated Sorted Array II

![](/files/-Mfw1JiI4qyP9s1dc37f)

time: O(logn), **in  11111 0 11111 this case, worst case is almost O(n)**

space: O(1)

```java
class Solution {
    public int findMin(int[] nums) {
        int left = 0;
        int right = nums.length - 1;
        while (left < right) {
            int mid = left + (right - left)/2;
            
            if (nums[mid] > nums[right]) {
                left = mid + 1;
            } else if (nums[mid] < nums[right]) {
                right = mid;
            } else { // nums[mid] == nums[right]
                right--;
            }
        }
        return nums[left];
    }
}
```
