Design a Probabilistic Map data structure with put and getAndRemoveRandom.
Unlock detailed company stats for this questionUpgrade
Design a Probabilistic Map data structure with the following operations:
- put(string key, string value): takes a key-value pair and inserts it into the map.
- getAndRemoveRandom(string key): takes a key and, if present, returns and removes a random value associated with the key.
Format · Technical interview.
Community answers
No answers contributed by the community yet.
Related questions
Design a restaurant waitlist API and data structure.Design a data structure with push() and randompop(), which removes a uniformly random element. Then extend it to pop each element with probability proportional to its weight.Design a data structure that supports insert, delete and getRandom in O(1).Related courses

Course

Course
Course
