...

/

DIY: Insert, Delete, and GetRandom in O(1)

DIY: Insert, Delete, and GetRandom in O(1)

Solve the interview question "Insert, Delete, and GetRandom in O(1)" in this lesson.

Problem statement

Implement a set data structure that can perform the following operations:

  • insert(obj, data): This function should insert data into the set (if the set does not contain it already). It should return false if the data already exists in the set. Otherwise, it should return true.
...