Insert Delete GetRandom O(1)

Hi Geeks! In this article, we going to see about how to insert, delete and get random elements with O(1) Time Complexity. Design a data structure that supports all following operations in average O(1) time. insert(val): Inserts an item val to the set if not already present.remove(val): Removes an item val from the set if present.getRandom: Returns a …

Continue reading Insert Delete GetRandom O(1)