Insert Delete GetRandom O(1)
Intuition First thought was to use a dictionary(hashmap) to keep track of the items, however the random is an issue, since we need to convert the dictionary into a list to get a random item. Approach In order to achieve time complexity near O(1) we need to use two structures. One dictionary for fast deletion, and a list for fast randomization. The trick that makes the possible is to remove an element from a list in O(1), and this is achieved by u ...