Pergunta de entrevista da empresa Bloomberg

For the coding interviews, I was given a problem to solve, for which they wanted pseudo-code (they didn't run it)