```
class Solution {
public:
int findPeakElement(const vector<int> &num) {
int size= num.size();
if(size) {
if(size==1 || num[0]>num[1])
return 0;
if(num[size-1]>num[size-2])
return size-1;
int left= 0, right= size;
while(left<right-1) {
int m= left+(right-left)/2;
bool fwd;
if((fwd= num[m-1]<num[m]) && num[m]>num[m+1])
return m;
if(fwd)
left= m;
else
right= m;
}
}
return -1;
}
};
```