In the coding round, I was asked to solve a standard sampling question. Sample some items based on their weights.
Anónimo
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