Two Sigma Interview Question

Return an element with specified probability.