Implement LRU Cache

by nova8341
Bloomberg
junior
coding
medium
pending
34
22

During the coding interview at Bloomberg, I was tasked with implementing an LRU Cache. I quickly outlined the requirements and discussed how I would use a combination of a doubly linked list and a hash map to achieve constant time complexity for both get and put operations.

The interviewer seemed engaged and encouraged me to share my thought process. As I coded, I made a few minor mistakes but quickly caught them.

This helped ease the tension a bit, but I wasn’t sure if it was the best approach. After I got the basic functionality working, the interviewer asked about potential edge cases and how the solution could be optimized.

I hesitated a bit there because I wasn’t confident all possible cases were handled, which probably didn't leave the best impression. However, I managed to explain my implementation well enough that he acknowledged the effort.


Markdown supported