```
class Solution {
public:
int findPeakElement(vector<int>& nums) {
int len=nums.size(),l=0,r=len-1;
while (l<=r) {
int mid=(l+r)>>1;
if (mid<len-1 && nums[mid+1]>nums[mid])
l=mid+1;
else
if (mid>0 && nums[mid-1]>nums[mid])
r=mid-1;
else
return mid;
}
}
};
```