Meta interviews feature this to assess your understanding of probability and binary search on prefix sums.
You're given an array w where w[i] is the weight of index i. Implement pickIndex() which returns index i with probability proportional to w[i].
For example, if w = [1, 3], pickIndex() should return about % of the time and about % of the time.
Constraints: , . pickIndex is called up to times.