Pregunta de entrevista de J.P. Morgan

Two questions in each probability, puzzles and coding.