Find the Runner-Up Score!

  • + 5 comments

    gtorrecilla. What do you think of this? Its not the best by line count, but I believe it finds the 2nd largest within O(n).

    max = max2 = -100 - int(raw_input())
    nums = map(int,raw_input().split(' '))
    for i in range(len(nums)):
        if nums[i] > max2:
            if nums[i] > max:
                max,max2 = nums[i],max
            elif nums[i] < max:
                max2 = nums[i]
    print(max2)