AlgoMaster Logo

Random Pick with Weight

weights=[1, 3, 2, 4],target=7
0 / 12
weights01132234
algomaster.io
Step:Start: Build prefix sum from weights, then binary search for target