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.
You're wrong. His code works. First he extracts the scores and puts them in a set, so that any duplicates are removed. Then he sorts the unique scores. Then he takes the second item from the sorted scores. This can only be the second-lowest score, it' can't possibly be anything else.
The code is inefficient, but it covers all the possible inputs (as long as the quarantee about there being a second-lowest score is kept - and Hackerrank tests always keep their promises about the input data).
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 →
You're wrong. His code works. First he extracts the scores and puts them in a set, so that any duplicates are removed. Then he sorts the unique scores. Then he takes the second item from the sorted scores. This can only be the second-lowest score, it' can't possibly be anything else.
The code is inefficient, but it covers all the possible inputs (as long as the quarantee about there being a second-lowest score is kept - and Hackerrank tests always keep their promises about the input data).