bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1244. Design A Leaderboard

1244. Design A Leaderboard

Leetcode Solutions

Approach: Brute Force

  1. Initialize a dictionary scores with playerId as the key and score as the value.
  2. addScore: Update the dictionary with the new score for the player. If the player doesn't exist, add them with the given score.
  3. top: Convert the dictionary values to a list, sort it in descending order, and sum up the first K elements.
  4. reset: Set the player's score to 0 in the dictionary.
UML Thumbnail

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...