Back to problems

Randomized Container

Object-Oriented Programming · Meta · Medium

Randomized Collection with Duplicates Medium · Topics · Company Tags · Hints Design a data structure that supports adding an element and removing a random element, both in constant average time. The structure should allow duplicate values: each insertion creates an independent copy, and the random removal treats every stored copy equally. Implement the RandomizedCollection class: RandomizedCollection() initializes an empty collection. boolean insert(T val) adds one…

Checking your access…