Hackerrank/Python

Find the Runner-Up Score!

.   2022. 2. 5. 13:40

[2, 10] 범위의 정수 n과 [-100, 100] 범위에 속한 n개의 정수를 입력받는다.

두번째로 높은 점수를 출력한다.

if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
    l = list(set(arr))
    if len(l) == 1:
        print(l[0])
    else:
        print(sorted(l)[-2])

 

Find the Runner-Up Score! | HackerRank

 

Find the Runner-Up Score! | HackerRank

For a given list of numbers, find the second largest number.

www.hackerrank.com