Pergunta de entrevista da empresa Google

Asked to solve a complex algorithm