티스토리 뷰

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

 

'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
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함