[C++] Simple solution O(n) Time


#1
int Solution::perfectPeak(vector<int> &A) {
    int n = A.size();
    vector<int> suff(n);
    int mn = INT_MAX;
    for(int i =n-1;i>=0;i--)
    {
        mn = min(mn,A[i]);
        suff[i] = mn;
    }
    priority_queue<int> pq;
    pq.push(A[0]);
    for(int i =1;i<n-1;i++)
    {
        if(pq.top()< A[i] && A[i]< suff[i+1])
            return 1;
        pq.push(A[i]);
    }
    return 0;
}