2021-04-24打卡
作者:
程博颖 | 来源:发表于
2021-04-24 22:57 被阅读0次
image.png
class Solution {
public int findMin(int[] nums) {
int min = nums[0];
for(int i=1;i<nums.length;i++){
if(nums[i] < min){
return nums[i];
}
}
return min;
}
}
image.png
class Solution {
public int findPeakElement(int[] nums) {
int left =0,right = nums.length-1;
while(left < right){
int mid = left+(right-left)/2;
if(nums[mid] > nums[mid+1]){
right = mid;
}else{
left = mid + 1;
}
}
return left;
}
}
本文标题:2021-04-24打卡
本文链接:https://www.haomeiwen.com/subject/qcrrrltx.html
网友评论