Design a Set with Uniform Random Sampling

Asked at Google · Coding Questions · Difficulty: Medium

Design a set of distinct values that can also hand back a random member, each member equally likely. Adding, removing, membership checks and sampling must all stay fast as the set grows, so no operation may scan the members.

Loading the problem…