LeetCode 528: Random Pick with Weight
Question
Given an array of positive numbers, return an index in this array based on the weight of the number occupying that index. For example, for w = [1, 3]
, the probability of picking the index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probabi...
interview-prep.hashnode.dev2 min read