Algorithm · Meta · Hard
Below are six independent coding tasks. You may be assigned any subset of them; for each one, implement the requested behavior and state the time and space complexity of your solution. Task 1: Weighted random index Create a class with two methods. The constructor receives an array weights; each element is a positive integer representing the relative weight of its index. The method pickIndex() draws an integer index $$i$$ with probability $$ \frac{weights[i]}{\sum_j…
Checking your access…