Pregunta de entrevista de Google

How would you solve this problem?