Description
Design a Leaderboard class with addScore(playerId, score), top(K) returning sum of top K scores, and reset(playerId).
Examples
Input:
addScore(1, 73), addScore(2, 56), addScore(3, 39), top(2)Output:
129Explanation:
Top 2 scores: 73 + 56 = 129.
Input:
addScore(5, 100), addScore(5, 50), addScore(3, 80), top(1)Output:
150Explanation:
Player 5 has accumulated scores: 100 + 50 = 150. Player 3 has 80. Top 1 score is player 5's total of 150.
Input:
addScore(10, 45), addScore(20, 67), addScore(30, 23), reset(20), addScore(20, 90), top(3)Output:
158Explanation:
Initial scores: player 10 has 45, player 20 has 67, player 30 has 23. After reset(20), player 20's score becomes 0. After addScore(20, 90), player 20 has 90. Top 3 scores: 90 + 45 + 23 = 158.
Constraints
- •
1 ≤ playerId, score ≤ 10000 - •
1 ≤ K ≤ number of players