Back to Question

Design a Set with $O(1)$ `insert`, `remove`, and `getRandom`

Question Explain

Design a data structure that supports inserting a value, removing a value, and getting a random element, all in $O(1)$ average time. This requires combining an Array and a Hash Map.

Start Trying This Question Simulation

Click "Start Speaking" and answer the question naturally.