Pergunta de entrevista da empresa Bloomberg

A coding question related to stack.