티스토리 뷰


[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
'Hackerrank > Python' 카테고리의 다른 글
Finding the percentage (0) | 2022.02.06 |
---|---|
Nested Lists (0) | 2022.02.06 |
List Comprehension (0) | 2022.02.05 |
Print Function (0) | 2022.02.05 |
Write a function (0) | 2022.02.05 |