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.
Climbing the Leaderboard
Climbing the Leaderboard
Sort by
recency
|
2358 Discussions
|
Please Login in order to post a comment
This short Python solution takes advantage of the fact that the player scores are listed in ascending order. We first make a sorted list of unique leader scores, then for each player score, removing the elements which are smaller than the player score, the length of the remaining leader scores plus one is thus the rank of the player score. The process is continued with the shorten leader scores list, thus saves a lot of steps.
My code doesn't pass the execution time limits, does anyone know why?. Here it is:
Simple solution using STL:lowerbound
My TypeScript. Probably could still be optimized, but I took an approach that takes advantage of the player array being sorted. i.e. As you iterate, the next score will either be the same or higher, so there is no need to go back through the whole ranked set each time to find the new ranking.