+ 2

Find the runner up score , help me in finding the mistake ...

# 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 n . The second line contains an array of n integers each separated by a space. # Output Format # Print the runner-up score. # Sample Input # 5 # 2 3 6 6 5 # Sample Output # 5 Here is my solution 👇👇👇 n = int(input()) a = input().split() # print(max(a)) m = a[0] for i in a: if m<i: m = i # finding the largest number m_1 = a[0] # print(m) for i in a: if m_1<i and i<m: m_1 = i # finding the 2nd largest number print(m_1)

10th Jun 2020, 10:07 AM
Anjali Singh
Anjali Singh - avatar
12 Respostas
12th Jun 2020, 1:04 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
The way I would have done it a="2 3 3 4 6 6 5" b=a.split() c=max(b) while c in b: b.remove(c) print(b) print(max(b)) I am trying to understand your solution tho your solution outputs right result if I am not wrong ,so i don't really understand what is the problem! Also I think the constraints in this solution would be no use of max? otherwise using max you can find it easily
10th Jun 2020, 10:19 AM
Abhay
Abhay - avatar
+ 3
Pls add a link of your hackerrank problm.
10th Jun 2020, 5:08 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Well you can easily add inputs in here , n=input() a=input()
10th Jun 2020, 10:31 AM
Abhay
Abhay - avatar
+ 2
yes
10th Jun 2020, 10:34 AM
Abhay
Abhay - avatar
+ 2
can you show what you are trying to do ? because I don't believe it will give runtime error
10th Jun 2020, 10:44 AM
Abhay
Abhay - avatar
+ 2
https://code.sololearn.com/cy5B2DigM43G/?ref=app Here its working properly bt the same code when i am submitting on hackerrank platform its giving run time error
10th Jun 2020, 10:52 AM
Anjali Singh
Anjali Singh - avatar
+ 2
C,Cpp,Java,Html. 𝐊𝐱𝐱𝐛𝐹 𝐆𝐡𝐚đČđšđ„ https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem there are some questions I have solved here on hackerrank bt while compiling it's giving me sometimes compilation error, syntax error and sometimes runtime error but I am not getting anyone of this error.
11th Jun 2020, 11:26 AM
Anjali Singh
Anjali Singh - avatar
+ 1
Abhay here we have to take two inputs bt u have not used input ?why
10th Jun 2020, 10:30 AM
Anjali Singh
Anjali Singh - avatar
+ 1
We can also wirte it as a = input().split() ....?
10th Jun 2020, 10:33 AM
Anjali Singh
Anjali Singh - avatar
+ 1
Bt when we are giving input in program. Its giving runtime error😐
10th Jun 2020, 10:35 AM
Anjali Singh
Anjali Singh - avatar