Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def findPeakElement(self, nums: List[int]) -> int:
- if len(nums) <= 1:
- return 0
- low, high = 0, len(nums) - 1
- while low <= high:
- mid = low + (high-low)//2
- if mid < len(nums) - 1 and nums[mid] < nums[mid+1]:
- low = mid + 1
- elif mid > 0 and nums[mid] < nums[mid-1]:
- high = mid - 1
- else:
- return mid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement