Day 12 of June LeetCode Challenge

Aanchal Patial
1 min readJun 12, 2020

Design a data structure that supports all following operations in average O(1) time.

  1. insert(val): Inserts an item val to the set if not already present.
  2. remove(val): Removes an item val from the set if present.
  3. getRandom: Returns a random element from current set of elements. Each element must have the same probability of being returned.

--

--

Aanchal Patial

We never really grow up, we only learn how to act in public