Leetcode 380. Insert Delete GetRandom O(1)
Design a data structure supporting insert(val), remove(val), and getRandom() — which returns a uniformly random existing element — with each operation in average O(1) time. The key challenge is to combine O(1) existence checks/updates with O(1) random access so every current element has equal selection probability.
Asked at:
Meta

Amazon
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late July, 2025
Senior
Mid May, 2025
Senior
With duplicate insertions allowed.
Mid April, 2025
Senior
Your account is free and you can post anonymously if you choose.