03 Dec Find the Runner-Up Score in
Hello Friends, How are you? Today I am going to solve the HackerRank Find the Runner-Up Score Problem in Python with a very easy explanation. In this article, you will get one or more approaches to solving this problem. So let’s start- {tocify} $title={Table of Contents} Given the participants’ score sheet for your University Sports Day, you are required to find the runner-up score. You are given n scores. Store them in a list and find the score of the runner-up. The first line contains n. The second line contains an array A[] of n integers each separated by a space. Print the runner-up score.
5 2 3 6 6 5 {codeBox}
5 {codeBox}
The given list is [2, 3, 6, 6, 5]. The maximum score is 6, the second maximum is 5. Hence, we print 5 as the runner-up score. Approach I: Find the Runner-Up Score HackerRank Python Solution
# ========================
# Information
# ======================== # Name: Find the Runner-Up Score in Python HackerRank
# Direct Link: https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem
# Difficulty: Easy
# Max Score: 10
# Language: Pypy 3 # ========================
# Solution Start
# ======================== #Find the Runner-Up Score in Python - Hacker Rank Solution if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) print(sorted(list(set(arr)))[-2]) #Find the Runner-Up Score in Python - Hacker Rank Solution END
# MyEduWaves
Sorry, the comment form is closed at this time.