In this HackerRank Find the Runner Up Score problem solution 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.
Problem solution in Python 2 programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT def max(l): return sorted(set(l))[-2] test = int(raw_input()) l = [int(_) for _ in raw_input().split()] print max(l)
Problem solution in Python 3 programming.
if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) arr = list(arr) x = max(arr) y = -9999999 for i in range(0,n): if arr[i]<x and arr[i] > y: y = arr[i] print(y)
Problem solution in pypy programming.
if __name__ == '__main__': n = int(raw_input()) arr = map(int, raw_input().split()) Max = max(arr) while max(arr) == Max: arr.remove(max(arr)) print max(arr)
Problem solution in pypy3 programming.
if __name__ == '__main__': n = int(input()) #print (input().split()) #arr = [int(x) for x in input().split()] #print (list(input())) arr = list(map(int, input().split())) #print (arr) #arr = sorted(arr) arr.sort() #print (arr) for i in range(n-1, -1, -1): if arr[i]<arr[n-1]: temp = arr[i] break print (temp) #sorted(arr) #print (arr[n-1])
In the Python 3 code, we just need upto -58 value for the code since the lowest in the test values is -57 (test case 1)
Hi may i know that value must be lesser than the max value but lesser than the lowest test value wouldnt any value in between those number qualify?