Store scores for players and produce a high score list

Posted by zrvan on Programmers See other posts from Programmers or by zrvan
Published on 2014-05-28T06:27:15Z Indexed on 2014/05/28 10:01 UTC
Read the original article Hit count: 134

Filed under:
|

This question is derived from an interview question that I got for a job I was declined. I have asked for code review for my solution at the dedicated Stack Exchange site. But I hope this question is sufficiently rephrased and asked with a different motivation not to be a duplicate of the other question.

Consider the following scenario:

You should store player scores in the server back end of a game. The server is written in Java.

Every score should be registered, that is, one player may have any number of scores for any number of levels.

A high score list should be produced with the fifteen top scores for a given level, but only one score per user (to the effect that even if player X has the two highest scores for level Y, only the first position is counted and player Z has the second place).

No information should be persisted and only Java 1.7+ standard libraries should be used. No third party libraries or frameworks are acceptable.

With the number of players as the primary factor, what would be the best data structure in terms of scalability and concurrency?

How would you access the structure to register a single score given a level and a player id?

How would you access the structure to compile the high score list?

© Programmers or respective owner

Related posts about java

Related posts about scalability