int peakIndexInMountainArray(vector<int>& A) {
    int Len = A.size();
    int position = -1;
    for (int i = 1; i < Len - 1; i++)
    {
        if (A[i] > A[i - 1] && A[i] > A[i + 1])
        {
            position = i;
            break;
        }
    }
    return position;
}

 

posted on 2018-09-27 13:48  Sempron2800+  阅读(123)  评论(0编辑  收藏  举报