Draft

Design a Leaderboard

7 of 9sergiodxa

Description:

Design a Leaderboard class with 3 functions:

  • addScore(playerId, score): When given an existing player, it increments their score, otherwise, it adds the player to the leaderboard with the given score.
  • top(k): Returns the sum of the scores of the top k players.
  • reset(playerId): Resets the score of the player with the given id to 0.

Note that initially, the leaderboard is empty.

Handle invalid cases for each function. E.g. Attempting to reset the score of a player who is not on the leaderboard.

Stats:

CreatedAug 4, 2020
Warriors Trained46
Total Skips0
Total Code Submissions105
Total Times Completed9
Ruby Completions7
JavaScript Completions5
Total Stars0
% of votes with a positive feedback rating38% of 8
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes4
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • sergiodxa Avatar
Ad