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