Algorithm · Pinterest · Medium
You are to implement weighted_random_sample(items, scores), where items is a list of strings and scores is a list of floating-point numbers with the same length as items. Each score may be any real value, so it can be negative or have a very large or very small magnitude. The function must return one string chosen from items, and the selection probability for items[i] must be proportional to a probability value obtained from scores[i]. The mapping from a raw score to a…
Checking your access…