Domanda di colloquio di J.P. Morgan

Two questions in each probability, puzzles and coding.