MongoDB Interview Question

Algorithm question regarding a well known game, the task was to code a small feature of such game.