bugtype 2019. 4. 28. 14:35

Input: [10, 5, 4, 3, -1]

Output: 5

Input: [3, 3, 3]

Output: Does not exist.

def solution(array):
    max1 = max2 = float('-inf')


    while(array):
        v = array.pop(0)
        if v > max1 and v > max2:
            max2 = max1
            max1 = v
        elif v < max1 and v > max2:
            max2 = v

    if (max2==float('-inf')):
        print("Does not exist.")
    else:
        print(max2)


solution([10,5,4,3,-1])
solution([10,999,20202,1010101,1010100,320,230,203,40,3402,3402,340,5,4,3,-1])
solution([3,3,3])