153. Find Minimum in Rotated Sorted Array

Posted reboot329

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了153. Find Minimum in Rotated Sorted Array相关的知识,希望对你有一定的参考价值。


June-21-2019

找到最小值。

二分,通过M和R的大小判断最小值在哪边,最后停留的位置[A, B]里AB的大小为止,所以比较一下。

    public int findMin(int[] nums) 
        int l = 0, r = nums.length - 1;
        while (l + 1 < r) 
            int m = l + (r - l) / 2;
            if (nums[m] > nums[r]) 
                l = m;
             else 
                r = m;
            
        
        return Math.min(nums[l], nums[r]);
    

以上是关于153. Find Minimum in Rotated Sorted Array的主要内容,如果未能解决你的问题,请参考以下文章

153. Find Minimum in Rotated Sorted Array

#Leetcode# 153. Find Minimum in Rotated Sorted Array

153. Find Minimum in Rotated Sorted Array

153. Find Minimum in Rotated Sorted Array

153 Find Minimum in Rotated Sorted Array

153. Find Minimum in Rotated Sorted Array