Pergunta de entrevista da empresa Confluent

Build a data structure with the following APIs: get, put, getAverage() Entries added to the data structure will expire.

Resposta da entrevista

Sigiloso

28 de jan. de 2022

Clarified: memory bounds. Interviewer said assume unbounded memory. Initial approach was to consider a smaller key space and a much larger timeseries space. This surprised the interviewer as it wasn't the solution he had in mind. Interviewer then clarified that he wanted a bounded timeseries space with a fixed expiration period. Went on to propose a solution with a HashMap and TreeMap. Interviewer pointed out that may be a TreeMap is not most optimal as it adds log(n). This was a good call out. So I replaced it with a single data structure: LinkedHashMap. The interviewer didn't like this as he was not familiar with the data structure. He wanted me to use structures that he was familiar with, so ultimately solved it with a HashMap and a Queue. I missed an edge case for the average calculation as I ran low on time. A lot of time was spent initially talking. Overall, it wasn't the best experience. I usually know when I didn't perform well in an interview, and expect the results. This was a bit different where I knew I performed alright but expected a reject because of how much the interviewer struggled. I suspect I was under leveled as evidenced by the interviewer pushing for a very specific solution, and struggling to comprehend alternate solutions.

3