You are viewing a single comment's thread. Return to all comments →
You can use sort() it is efficient than sorted() as it does in-place sorting. They used sorted, so that they write it in lesser number of characters.
sort()
sorted()
sort() returns None whereas sorted() returns the newly created list.
None
Using sort() :
n=input() nums=set(map(int),input().split()) nums.sort() #here in-place sorting takes place print (nums[-2])
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Runner-Up Score!
You are viewing a single comment's thread. Return to all comments →
You can use
sort()
it is efficient thansorted()
as it does in-place sorting. They used sorted, so that they write it in lesser number of characters.sort()
returnsNone
whereassorted()
returns the newly created list.Using
sort()
: