public class Solution {
public int findMin(int[] nums) {
if(nums == null){
return 0;
}
int lo = 0, hi = nums.length - 1;
int target = nums[hi];
while(lo + 1 < hi){
int mid = lo + (hi - lo) / 2;
if(nums[mid] < target){
hi = mid;
}else{
lo = mid;
}
}
return nums[lo] < nums[hi] ? nums[lo] : nums[hi];
}
}
[LeetCode] 153. Find Minimum in Rotated Sorted Array
最新推荐文章于 2023-11-12 21:10:53 发布