Pregunta de entrevista de Google

Asked to solve a complex algorithm