Find The Runner-Up Score ( HackerRank)

 Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given  scores. Store them in a list and find the score of the runner-up.

Input Format

The first line contains . The second line contains an array   of  integers each separated by a space.

Constraints

Output Format

Print the runner-up score.


## Solution:--

if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
    arr1=sorted(list(set(arr)))
    
    
    if (len(arr1)==1):
        print(arr1[0])  ## For checking array of Only two elements.
        
        
    else:
        print(arr1[-2])  ## It will give correct runner-up for more than two elements.


Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions