← Questions

Insert, delete and get random in O(1)

0
UberMetaSpaceXAICodingLast asked May 2026

Design a set with insert(val), remove(val) and get_random(), each in average O(1) time. get_random returns each current element with equal probability.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding