Problem 380 · Medium

Insert Delete GetRandom O(1)

Design a set that supports insert, delete and returning a random stored value, all in constant average time. The visual keeps values in an array and tracks each value's position with a map.

Open the interactive visualisation