LinkedIn may need to sample content candidates according to configured exposure weights. Given positive weights and uniformly distributed random values, return the selected index for each random value.
Implement weighted_random_pick(weights, random_values).
weights is a list of positive integers, where weights[i] is the relative probability of selecting index i.random_values is a list of real numbers, each satisfying 0 <= value < sum(weights). Each value represents an independent uniform draw from the total weight range.r, return the smallest index i whose cumulative weight is greater than r.The interval [prefix[i - 1], prefix[i]) maps to index i, with prefix[-1] treated as 0.
def weighted_random_pick(weights, random_values):