We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Tried to keep using NestedList till the end since it was specifically mentioned, and came up with this. Feel free to point out errors, if any, and comment down if you have an optimized yet readable solution for the same.
`
if name == 'main':
studentlist = []
newlist = []
finallist = []
for _ in range(int(input())):
name = input()
score = float(input())
studentlist.append([name, score])
# Sorting student's score in ascending order
studentlist.sort(key=lambda x: x[1])
# Adding student's score which are higher than minimum score to a newlist
for i in studentlist:
if i[1] != studentlist[0][1]:
newlist.append(i)
# Adding all the student's of newlist with the lowest score to the finallist
for i in newlist:
if i[1] == newlist[0][1]:
finallist.append(i)
# Sorting student's name alphabetically in the final list
finallist.sort()
[print(x[0]) for x in finallist]
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Lists
You are viewing a single comment's thread. Return to all comments →
Tried to keep using NestedList till the end since it was specifically mentioned, and came up with this. Feel free to point out errors, if any, and comment down if you have an optimized yet readable solution for the same.
`
if name == 'main':