public int findMin(int[] num) {
int s = 0;
int e = num.length-1;
int m;
while(s<e){
m = (s+e)/2;
if(num[m]>=num[s] && num[s] > num[e])
s = m+1;
else
e = m;
}
return num[s];
}
网上一个大牛的解法,就是如果中间比两边大了,就往右走。不然转点在前面
Find Minimum in Rotated Sorted Array - Leetcode (Java)
最新推荐文章于 2022-07-27 13:01:15 发布