Insert Delete GetRandom O(1)
Asked in the Coding 1 stage. Implement a data structure supporting insertion, deletion, and returning a random stored value, each in average O(1) time. Reported follow-up: extend the solution to allow duplicates.
For grading, implement randomized_set(operations). Each operation is ['insert', value], ['delete', value], or ['getRandom']. Return a list containing Boolean results for insert/delete and the selected value for getRandom. getRandom is called only when the set is non-empty.
def randomized_set(operations):