class Solution(object):
def findMin(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums :
return - 1;
l, r = 0, len(nums) - 1
while l < r :
mid = l + (r - l) / 2
if nums[mid] > nums[r] :
l = mid + 1
elif nums[mid] < nums[r] :
r = mid
else :
r -= 1
return nums[l]
public class Solution {
public int findMin(int[] nums) {
int l = 0, r = nums.length - 1;
while (l < r) {
int m = (l + r) >> 1;
if (nums[m] > nums[r]) l = m + 1;
else if (nums[m] < nums[r]) r = m;
else r--;
}
return nums[l];
}
}
public class Solution {
public int findMin(int[] nums) {
if (nums == null || nums.length < 1) return -1;
int i = 0;
int j = nums.length - 1;
while (i < j) {
if (nums[i] < nums[j]) return nums[i];
int mid = i + (j - i) / 2;
if (nums[mid] > nums[j]) {
i = mid + 1;
} else if (nums[mid] == nums[j] && nums[mid] == nums[i]) {
j--;
i++;
} else {
j = mid;
}
}
return nums[j];
}
}