key: this is asking the first element smaller than target = nums[last]
class Solution {
public int findMin(int[] nums) {
if(nums == null) return -1;
int left = 0;
int right = nums.length -1;
int target = nums[right];
while(left + 1 < right){
int mid = left + (right-left)/2;
int midVal = nums[mid];
if(midVal <= target){
right = mid;
}else{
left = mid;
}
}
if(nums[left] < nums[right]) return nums[left];
else return nums[right];
}
}