Random set
Your task
Design a set supporting insert(x), remove(x), and get_random() each in average O(1). Since randomness is hard to test deterministically, instead of true randomness, get_random must return the element currently stored at internal index (call_counter % current_size) where call_counter starts at 0 and increments on each get_random call. insert returns 1 if x was newly added (0 if already present); remove returns 1 if x was present and removed (0 otherwise). Replay ["insert", x], ["remove", x], ["getRandom"] and return the list of all results in order.
Examples
random_set(ops: list[list]) -> list[int]Example 1
Input
random_set([["insert", 1], ["remove", 2], ["insert", 2], ["getRandom"], ["remove", 1], ["insert", 2], ["getRandom"]])Output
[1, 0, 1, 1, 1, 0, 2]