Question d’entretien chez Bloomberg

the brain teaser, and the program correctness problem