Climbing the Leaderboard
An arcade game player wants to climb to the top of the leaderboard and track their ranking. The game uses Dense Ranking , so its leaderboard works like this:
- The player with the highest score is ranked number
1on the leaderboard.
- Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately following ranking number.
ranked = [100, 90, 90, 80] player = [70, 80, 105]
The ranked players will have ranks
3, respectively. If the player’s scores are
105, their rankings after each game are
[4, 3, 1].
Complete the climbingLeaderboard function in the editor below.
climbingLeaderboard has the following parameter(s):
- int ranked[n]: the leaderboard scores
- int player[m]: the player’s scores
- int[m]: the player’s rank after each new score
Read more on the challenge page…
I’m providing the solution for Python and JS, please leave on the comments if you found a better way.
If you liked what you saw, please support my work!
Juan Cruz Martinez
Juan has made it his mission to help aspiring developers unlock their full potential. With over two decades of hands-on programming experience, he understands the challenges and rewards of learning to code. By providing accessible and engaging educational content, Juan has cultivated a community of learners who share their passion for coding. Leveraging his expertise and empathetic teaching approach, Juan has successfully guided countless students on their journey to becoming skilled developers, transforming lives through the power of technology.