Two Sigma interview question

Return an element with specified probability.