← All problemsSign in

380. Insert Delete GetRandom O(1)

LeetCodeArrayHash TableMathDesignRandomizedOpen on judge ↗

Implement the RandomizedSet class: - RandomizedSet() Initializes the RandomizedSet object. - bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise. - bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise. - int getRandom() Returns a random element from the

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start