Day 5 of June LeetCode Challenge

Aanchal Patial
1 min readJun 5, 2020

--

Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight.

Note:

  1. 1 <= w.length <= 10000
  2. 1 <= w[i] <= 10^5
  3. pickIndex will be called at most 10000 times.

--

--

Aanchal Patial

We never really grow up, we only learn how to act in public