Weighted reservoir sampling in one pass
Asked at Jane Street, Jump Trading
A stream emits (item, weight) pairs, with positive weights, and you never learn the length. You want a sample of k items where each item's chance of ending in the sample is proportional to its weight, not uniform.
Implement weighted reservoir sampling in one pass using memory.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.