```
class Solution:
# @param nums, an integer[]
# @return an integer
def findPeakElement(self, nums):
b = 0
e = len(nums) - 1
while b <= e:
mid = (b+e) / 2
if b == e:
return b
if b+1 == e:
return b if nums[b] > nums[e] else e
if nums[mid-1] < nums[mid] > nums[mid+1]:
return mid
elif nums[mid-1] < nums[mid] < nums[mid+1]:
b = mid
else:
e = mid
return mid
```