Pregunta de entrevista de Bloomberg

It was a Coding Problem about Algorithms