153. Find Minimum in Rotated Sorted Array **

原创 2016年08月28日 19:57:50

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.

https://discuss.leetcode.com/topic/4100/compact-and-clean-c-solution/9

I have thought of this method, but got confused about the ending condition.

class Solution(object):
    def findMin(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        low =0
        high = len(nums)-1
        while low < high:
            if nums[low]<nums[high]:
                return nums[low]
            mid = (low+high)/2
            if nums[mid]>= nums[low]:
                low = mid +1
            else:
                high = mid
        return nums[low]

版权声明:本文为博主原创文章,未经博主允许不得转载。

[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 ...

【leetcode】153. Find Minimum in Rotated Sorted Array

【leetcode】153. Find Minimum in Rotated Sorted Array

【leetcode】No.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 mig...

Find Minimum in Rotated Sorted Array - LeetCode 153

题目描述: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 ...
  • bu_min
  • bu_min
  • 2015年04月24日 21:50
  • 275

LeetCode - 153. Find Minimum in Rotated Sorted Array

O(n)和使用Arrays.sort(nums)的方法就不再写了。真是各种花式使用二分搜索啊...二分搜索的关键点在与left,right指针移动条件的判定,这道题目的判定条件非常巧妙。使用nums[...

LeetCode-153.Find Minimum in Rotated Sorted Array

https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/ Suppose a sorted array is rota...

[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 ...

153和154. Find Minimum in Rotated Sorted Array II

Follow up for “Find Minimum in Rotated Sorted Array”: What if duplicates are allowed? Would ...

【LeetCode-面试算法经典-Java实现】【153-Find Minimum in Rotated Sorted Array(找旋转数组中的最小数字)】

【153-Find Minimum in Rotated Sorted Array(找旋转数组中的最小数字)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题  Suppose...

153. Find Minimum in Rotated Sorted Array\229. Majority Element II\Moore's voting algorithm

Find Minimum in Rotated Sorted Array 题目描述 代码实现153. Find Minimum in Rotated Sorted Array题目描述一个已经排好序的数...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:153. Find Minimum in Rotated Sorted Array **
举报原因:
原因补充:

(最多只允许输入30个字)