'cannot pass grading but no issue in stress test_Coursera Algorithmic toolbox: Programming Assignment 1: Maximum Pairwise Product

I wrote the code below but cannot figure out why I cannot pass the coursera grading but found no issue in stress test. the grader output is : Failed case #4/17: Wrong answer (Time used: 0.04/5.00, memory used: 22884352/2147483648.)

# cannot pass coursera grading, don't know why

def pairwise_product_self(numbers):
    n = len(numbers)
    max_i = 0
    for i in range(n):
        if numbers[i] > max_i:
            max_i = numbers[i]
            global max_i_idx 
            max_i_idx = i

    del numbers[max_i_idx]
    max_j = 0
    for j in range(n - 1):
        if numbers[j] > max_j:
            max_j = numbers[j]

    return max_i * max_j



if __name__ == '__main__':
    n = int(input())
    numbers = [int(x) for x in input().split()]
    print(pairwise_product_self(numbers))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source