:type nums: List[int] :rtype: int
(self, nums)
| 34 | """ |
| 35 | class Solution(object): |
| 36 | def findPeakElement(self, nums): |
| 37 | """ |
| 38 | :type nums: List[int] |
| 39 | :rtype: int |
| 40 | """ |
| 41 | |
| 42 | length = len(nums) |
| 43 | |
| 44 | for i in range(1, length-1): |
| 45 | if nums[i-1] < nums[i] > nums[i+1]: |
| 46 | return i |
| 47 | |
| 48 | if length <= 2: |
| 49 | return nums.index(max(nums)) |
| 50 | else: |
| 51 | if nums[0] > nums[1]: |
| 52 | return 0 |
| 53 | elif nums[-1] > nums[-2]: |
| 54 | return length-1 |
| 55 | return None |
nothing calls this directly
no outgoing calls
no test coverage detected