Pregunta de entrevista de Dropbox

It was an algorithm problem and I did not pass