【leetcode】【153】Find Minimum in Rotated Sorted Array


一、問題の説明
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e.,  0 1 2 4 5 6 7  might become  4 5 6 7 0 1 2 ).
Find the minimum element.
You may assume no duplicate exists in the array.
二、問題分析
変異の二分検索.
三、Java ACコード
public int findMin(int[] nums) {
        int left = 0, right = nums.length-1;
		while(left<right && nums[left]>nums[right]){
				int mid = (left + right)/2;
				if (nums[mid]<nums[right]) {
					right = mid;
				}else {
					left = mid + 1;
				}
		}
		return nums[left];
    }