Pregunta de entrevista de Nikura

How would you do to solve this problem? (in reference to a described problem)