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 ...
  • SunnyYoona
  • SunnyYoona
  • 2015年01月31日 17:21
  • 1480

153.Find Minimum in Rotated Sorted Array [LeetCode Java实现]

题目链接:find-minimum-in-rotated-sorted-array 有待继续优化代码结构,但是已经AC了 /** * Suppose a sorted array is...
  • ever223
  • ever223
  • 2015年03月19日 19:03
  • 881

leetcode 153: Find Minimum in Rotated Sorted Array

Find Minimum in Rotated Sorted Array Total Accepted: 21207 Total Submissions: 65855 Suppose a so...
  • xudli
  • xudli
  • 2014年12月30日 04:30
  • 2105

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...
  • feliciafay
  • feliciafay
  • 2015年01月21日 06:04
  • 1896

LeetCode(154) Find Minimum in Rotated Sorted Array II

题目如下: Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would t...
  • feliciafay
  • feliciafay
  • 2015年01月21日 09:10
  • 966

Find Minimum in Rotated Sorted Array -- LeetCode

这道题是Search in Rotated Sorted Array的扩展,区别就是现在不是找一个目标值了,而是在bst中找最小的元素。主要思路还是跟Search in Rotated Sorted ...
  • linhuanmars
  • linhuanmars
  • 2014年10月25日 07:11
  • 15951

Find Minimum in Rotated Sorted Array II -- LeetCode

这道题是Search in Rotated Sorted Array的扩展,思路在Find Minimum in Rotated Sorted Array中已经介绍过了,和Find Minimum i...
  • linhuanmars
  • linhuanmars
  • 2014年10月25日 07:12
  • 13802

【LeetCode】【Solution】Find Minimum in Rotated Sorted Array I & II

【题目】 Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 ...
  • ljiabin
  • ljiabin
  • 2014年11月10日 22:25
  • 3083

Leetcode Find Minimum in Rotated Sorted Array 题解

Leetcode Find Minimum in Rotated Sorted Array 题目大意,对一个有序数组翻转, 就是随机取前K个数,移动到数组的后面,然后让你找出最小的那个数,注意,K有可...
  • xindoo
  • xindoo
  • 2014年10月22日 09:08
  • 1200

[C++]LeetCode: 80 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 ...
  • cinderella_niu
  • cinderella_niu
  • 2015年01月09日 10:56
  • 632
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:153. Find Minimum in Rotated Sorted Array **
举报原因:
原因补充:

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