Pregunta de entrevista de Toptal

You need to complete an algorithmic task