题目链接:https://leetcode.com/problems/peak-index-in-a-mountain-array/description/
题目解析:只要找到非递增点就可以。
代码如下:4ms Accepted beating 100%
class Solution {
public:
int peakIndexInMountainArray(vector<int>& A) {
int pos;
for (pos = 0; pos < A.size(); pos++)
if (A[pos] > A[pos + 1])
break;
return pos;
}
};
static const auto ____ = [] () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
return nullptr;
}();