Insert Delete GetRandom o(1) Solution

In this problem, We have to design a data structure that supports Insert, Delete, and GetRandom in average O(1) time.

OR

Design a data structure that supports insert, delete, and getRandom in constant time O(1).

insert(value): Inserts an item value to the set if it’s not present.

remove(value): Removes an item value from the set if present.

getRandom(): Returns a random element from current set of elements. Each element must have the same probability of being returned.