J.P. Morgan interview question

Two questions in each probability, puzzles and coding.