class Solution {
public int findMin(int[] nums) {
int p = 0;
int r = nums.length - 1;
if(nums.length == 0) {return -1;}
while(p < r){
if(nums[p+1] >= nums[p]){
p++;
} else {
return nums[p+1];
}
if(nums[r] >= nums[r - 1]){
r –;
}else
{
return nums[r];
}
}
return nums[0];
}
}