Accepted log(n) in python


  • -1
    X
    class Solution(object):
        def findMin(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            if not nums:return None
            n = len(nums)
            left = 0; right = n-1
            while left + 1 < right:
                mid = (left+right)/2
                if nums[mid] > nums[-1]:
                    left = mid
                elif nums[mid] < nums[-1]:
                    right = mid
            if nums[left] < nums[right]:
                return nums[left]
            else:
                return nums[right]

Log in to reply
 

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