You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index.
Implement the Solution class:
Solution(int[] w)— initializes the object with the arrayw.int pickIndex()— returns a random index, weighted proportionally tow[i].
Example:
w = [1, 3] → pickIndex returns 0 with 25% probability, 1 with 75% probability.