Medium
060Random Pick with Weight
Given weights and random target values in [1,totalWeight], return the picked index for each target using weighted prefix ranges.
EXAMPLES
Example 1
Input
{
"w": [
1,
3
],
"targets": [
1,
2,
4
]
}
Output
[
0,
1,
1
]FUNCTION SHAPE
w: intArraytargets: intArray→intArray