[LeetCode] Insert Delete GetRandom O(1) - Duplicates allowed

1 · · May 3, 2022, 5:10 a.m.
381. Insert Delete GetRandom O(1) - Duplicates allowed RandomizedCollection is a data structure that contains a collection of numbers, possibly duplicates (i.e., a multiset). It should support inserting and removing specific elements and also removing a random element. Implement the RandomizedCollection class: RandomizedCollection() Initializes the empty RandomizedCollection object. bool insert(int val) Inserts an item val into the multiset, even if the item is already present. Returns true if...