Leetcode 162. Find Peak Element

Daniel Mesizah
2 min readJul 13, 2021

QUESTION:

SOLUTION:

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…

--

--

Daniel Mesizah

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