Leetcode 162. Find Peak Element

class Solution(object):
def findPeakElement(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
# if there is only 1 item, then return index 0
if len(nums) <= 1:
return 0
left = 0
right = len(nums) - 1
while left < right:
# instead of (left+right)// 2…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Daniel Mesizah

Daniel Mesizah

Coder who likes to share what he knows with the rest of the world