Why Partially Correct Solution?


#1

int Solution::perfectPeak(vector &A) {
int n=A.size();
vector max(n);
vector min(n);
int num=0;
min[n-1] = A[n-1];
max[0]=A[0];
for(int i=1;i<A.size();i++)
{
if(A[i]>max[i-1])
max[i]=A[i];
else
max[i]=max[i-1];
}
for(int i=n-2;i>=0;i–)
{
if(A[i]<min[i+1])
min[i]=A[i];
else
min[i]=min[i+1];
}
for(int i=1;i<n-1;i++)
{
if(A[i]==max[i] && A[i]==min[i])
num=1;
}

return num;

}


#2

Your solution is missing out “Strictly”.
Try these testcases :
5 1 2 5 8 6
your solution will return true for 3rd index i.e. the second 5 however it is not correct As it’s not strictly greater than elemnts on its left.