mrk-andreev / inmemory-leaderboard-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InMemory Leaderboard JS

InMemory implementation of "1244. Design A Leaderboard" leetcode problem.

Design a Leaderboard class, which has 3 functions:
- addScore(playerId, score) - update the leaderboard by adding score to the given player's score. 
- sumTop(K) - return the score sum of the top K players
- reset(playerId) - reset score for player

Constaint:
* score > 0
const Leaderboard = require('inmemory-leaderboard-js');

const service = new Leaderboard();

service.addScore(1, 42.0);
service.addScore(1, 42.0);
service.addScore(2, 42.0);
service.sumTop(5);
service.reset(1);

Installation

Install the package with npm:

npm install inmemory-leaderboard-js

Author

Mark Andreev, SWE @ Conundrum AI (https://www.linkedin.com/in/mrk-andreev/)

About

License:Apache License 2.0


Languages

Language:JavaScript 100.0%