For a test case it works on custom input but fails on submit. any help?


#1

Comment body goes here. public int perfectPeak(int[] A) {
int[] left = new int[A.length];
int[] right = new int[A.length];
left[0] = A[0];
right[A.length -1] = A[A.length-1];
for(int i =1; i < A.length; i++) {

        left[i] = Math.max(left[i-1], A[i]);
        
        
    }
      
    
    for(int i =A.length -2; i>=0; i--) {
        right[i] = Math.min(A[i], right[i+1]);
        
        
        if(right[i] == left[i] && A[i] == left[i] && i != 0) {
            return 1;
        }
    }
    
    return  0;
}