Today’s blog post is about an interesting problem that has been posted on the 5th day of LeetCode’s June 2020 challenge.

The entire problem statement is available here. Here’s an example to follow along with the given description.

Imagine, we have an array of positive integers like: [3, 14, 1, 7] where the values at a particular index represents a weight corresponding to that index. So, index 0 has a weight of 3, index 1 has a weight of 14 and so on. We have to write a function pickIndex() that randomly picks an index proportional to it’s weight (i.e…

Arkadev Ghosh

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store