# 154. Find Minimum in Rotated Sorted Array II

![](https://4272748102-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LekNH5IywF8mjBxFcnu%2F-MfvteCuNBjM1-DIv15B%2F-Mfw1JiI4qyP9s1dc37f%2Fimage.png?alt=media\&token=08f294d6-9906-4d0d-ba25-007f73f090ee)



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];
    }
}
```
