文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. Description
2. Solution
class Solution {
public:
int peakIndexInMountainArray(vector<int>& A) {
int left = 0;
int right = A.size() - 1;
while(left < right) {
int mid = (left + right) / 2;
if(A[mid] > A[mid + 1]) {
right = mid;
}
else {
left = mid + 1;
}
}
return left;
}
};