DIY: Insert, Delete, and GetRandom in O(1)
Explore how to implement a set data structure in Elixir with operations to insert, delete, and return random elements all in constant time. Understand the algorithms and design patterns needed to solve Amazon-style interview problems efficiently.
We'll cover the following...
We'll cover the following...
Problem statement
Implement a set data structure that can perform the following operations:
insert(obj, data): This function should insertdatainto the set (if the set does not contain it already). It should returnfalseif thedataalready exists in the set. Otherwise, it should returntrue.