Random Pick with Weight at Meta

Medium48.9% acceptance

This problem has 87.5% frequency at Meta.

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 hints

Topics

Also asked at 25 companies


More Meta Questions

View all Meta questions