Leetcode 162. Find Peak Element
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…