It's an on-site technical interview for an internship position in a small trading company. The question was given orally.
We want to save key and value pairs into a hashmap. The problem is that we have limited space, so we should delete pairs that are not accessed in a certain amount of time. Each time, we can either add/update key, value pair or try to get the value of a certain key.
Here's an example, suppose that entries should be deleted after 3 unit of time
ka va 1 // add key ka, value va, at time 1
kb vb 1 // add key kb, value vb, at time 1
vb 2 // try to access vb at time 2In the example, at time 4 entry ka,va should be deleted while kb,vb should still remain.
Here was my solution:
I was rejected the second the interview ended, so my solution was really bad lol.