Pregunta de entrevista de Scopely

Gave small assignment to solve?