Pergunta de entrevista da empresa Amazon

coding question about weighted random number generator