Your question is Constant-Time Randomized Set. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Match Group services need a lightweight set of active profile identifiers that supports fast updates and random profile selection. Implement randomized_set(operations, seed) so every insert, delete, and getRandom operation runs in average O(1) time.
operations is a list of two-element lists: [operation, value] for insert and delete, or ['getRandom', null] for random selection.operation is one of 'insert', 'delete', or 'getRandom'.value is an integer when required and null for getRandom.insert and delete return booleans. getRandom returns one currently stored integer.seed to make random selections reproducible during testing. The returned value must be uniformly selected from the current set.getRandom when the set is empty.def randomized_set(operations, seed):