Question
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.
random_set(ops: list[list]) → list[int][[["insert",1],["remove",2],["insert",2],["getRandom"],["remove",1],["insert",2],["getRandom"]]]out[1,0,1,1,1,0,2]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.