Why my solution fail for this test case?


#1

def perfectPeak(self, A):
n = len(A)
l = [0]*n
r = [0]*n

    ma = 0
    for i in range(n):
        l[i] = ma
        ma = max(ma, A[i])
    
    # print(l)
    mi = 1 * sys.maxsize
    for i in range(n-1,-1,-1):
        r[i] = mi
        mi = min(mi, A[i])
    # print(r)   
    for i in range(1,n-2):
        if l[i] < A[i] < r[i]:
            return 1
            
    return 0

Test case: A : [ 9895, 30334, 17674, 23812, 20038, 25668, 6869, 1870, 4665, 27645, 7712, 17036, 31323, 8724, 28254, 28704, 26300, 25548, 15142, 12860, 19913, 32663, 32758 ]
Expected result: 1
My result: 0