154. Find Minimum in Rotated Sorted Array II

class Solution {
    public int findMin(int[] nums) {
        int lo=0;
        int hi=nums.length-1;
        while(lo<hi)
        {
            int mid=(lo+hi)/2;
            if(nums[mid]<nums[hi])
                hi=mid;
            else if(nums[mid]>nums[hi])
                lo=mid+1;
            else
                hi--;
        }
        return nums[lo];
    }
}

  

posted @ 2017-10-24 01:05  Weiyu Wang  阅读(125)  评论(0编辑  收藏  举报