Pergunta de entrevista da empresa Bloomberg

the brain teaser, and the program correctness problem