LC: 1244. Design A Leaderboard - spiralgo/algorithms GitHub Wiki

1244. Design A Leaderboard:

The Essence:

Because of the fact that the addScore and reset methods are keep changing the values of the players, the top method requires an efficient method of returning these players in sorted order.

Details:

The list of players can be kept in sorted order in few ways:

  1. An array list can be used, which is fast for binary searching but slow for the insertion.
  2. A linked list can be used, which is fast for insertion but slow for binary searching. Reset/removal can be supported by a hash table.
  3. Various forms of tree structures can be used. These are harder to implement but can do both insertion and searching fast.