Simple Python Solution


  • 0
    Y
    def findPeakElement(self, nums):
            
            low = 0
            high = len(nums) - 1
            mid1 = (low + high) /2
            mid2 = mid1 + 1
            
            while(low < high):
                mid1 = (low + high) /2
                mid2 = mid1 + 1
                if nums[mid1] < nums[mid2]:
                    low = mid2
                else:
                    high = mid1
            return low

Log in to reply
 

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