Random Pick with Weight at Coinbase
Medium48.9% acceptance
This problem has 75.0% frequency at Coinbase.
Problem Description
You are given a **0-indexed** array of positive integers `w` where `w[i]` describes the **weight** of the `ith` index. You need to implement the function `pickIndex()`, which **randomly** picks an index in the range `[0, w.length - 1]` (**inclusive**) and returns it. The **probability** of picking...
Read full problem and hintsTopics
Also asked at 25 companies
More Coinbase Questions
Simple Bank SystemMediumTime Based Key-Value StoreMediumText JustificationHardFind the Length of the Longest Common PrefixMediumBest Time to Buy and Sell StockEasy
View all Coinbase questions