Practice/Uber/Leetcode 1244. Design A Leaderboard
CodingMust
You are tasked with implementing a leaderboard system for an online gaming tournament. The leaderboard must efficiently track player scores and support the following operations:
Your implementation should handle frequent score updates and top-K queries efficiently.
Leaderboard class with the three methods described aboveaddScore multiple times for the same player adds to their existing scoretop(K) method should return the sum of the K highest scores currently on the leaderboardreset method completely removes a player's score from the leaderboardExample 1:
` Operations: addScore(1, 100) addScore(2, 80) addScore(3, 90) top(2)
Output: 190 Explanation: The top 2 scores are 100 (player 1) and 90 (player 3), sum = 190 `
Example 2:
` Operations: addScore(1, 50) addScore(1, 30) addScore(2, 60) top(1)
Output: 80 Explanation: Player 1's cumulative score is 80 (50 + 30), which is the highest `
Example 3:
` Operations: addScore(1, 100) addScore(2, 90) reset(1) top(2)
Output: 90 Explanation: After resetting player 1, only player 2's score of 90 remains `