Domanda di colloquio di Ubisoft

Algorithm problem, with an attention to memory complexity.