Microsoft Interview Question

the coding question is about probability. you should use random number to create expected behaviour.