Binary search solution

  • 0
    class Solution(object):
        def findMin(self, nums):
            :type nums: List[int]
            :rtype: int
            if not nums: return 0
            i, j = 0, len(nums)-1
            while(i < j):
                k = (i+j)/2
                if nums[k] > nums[k+1]:
                    return nums[k+1]
                if nums[k] >= nums[i]:
                    i = k+1
                    j = k
            return nums[0]

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.