Pregunta de entrevista de Meta

In the coding round, I was asked to solve a standard sampling question. Sample some items based on their weights.

Respuesta de la entrevista

Anónimo

11 oct 2024

Convert weights to probabilities, then arrange these probabilities in a line. Sample a random number between 0 and 1, and finally use binary search to find the interval that this sampled number lies in