Morgan Stanley interview question

Code, Probability, a tricky stats question