Binary search solution


  • 0
    S
    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
                else:
                    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.