Back to QuestionsPractice with This Question
Design a Set with $O(1)$ `insert`, `remove`, and `getRandom`
97.1K views•Asked at Google•
Medium
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
Practice answering orally or with text to get instant AI feedback.