Pergunta de entrevista da empresa Bloomberg

Some simple coding problem, don't remember the details