Solution using upper_bound() and lowerr_bound()


#1

int Solution::perfectPeak(vector &A) {
int N = A.size();
for(int i = 1; i < N-1; i++) {
auto it1 = upper_bound(A.begin(),A.begin()+i,A[i]);
auto it2 = lower_bound(A.begin()+i+1,A.end(),A[i]);
if(it1 == A.begin()+i && it2 == A.end()) {
return 1;
}
}
return 0;
}