프로그래밍/LeetCode

[LeetCode][Python3] 162. Find Peak Element

snoopybox 2019. 1. 25. 01:15

Problem :

https://leetcode.com/problems/find-peak-element/


My Solution :

class Solution:
def findPeakElement(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
low, high = 0, len(nums)-1
while low < high:
mid = (low + high) // 2
if nums[mid] > nums[mid+1]:
high = mid
else:
low = mid+1
return low