Concise O(logN) python solution


  • 0
    N
    class Solution(object):
        def findPeakElement(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            l, r = 0, len(nums) - 1
            while l < r:
                m = (l + r) / 2
                if nums[m] < nums[m+1]:
                    l = m + 1
                else:
                    r = m
            return l
    

Log in to reply
 

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