In the previous exercise I wrote a solution that doesn’t work, so I guess I have to try again with two moreĀ Amazon interview questions:

Create a set data structure that provides the following operations, which must all operate in constant time: insert, delete, member?, and random. The random operation should return a random element from the set.

and

Given an array, find the first element that appears an even number of times.

Your task is to answer the two interview questions. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2