Implement LRU Cache

by phantom_flare749
Netflix
senior
coding
medium
pending
4
201

During the coding interview at Netflix, I was tasked with implementing an LRU Cache. I immediately began by outlining the core requirements and discussing the data structure choices.

A combination of a hash map for O(1) access and a doubly linked list for tracking the order of usage seemed like the most efficient solution. As I started coding, I implemented the core get and put methods while explaining my rationale to the interviewer.

There were moments where I hesitated, especially when ensuring proper node insertion and deletion from the linked list. The interviewer was supportive, asking clarifying questions that encouraged me to refine my approach further.

At one point, I got tripped up while discussing edge cases, like handling cache size limits, which could have been avoided with a bit more thorough preemptive thinking. Ultimately, I completed the implementation with all test cases passing but felt a bit flustered during the process.

The interviewer complimented the speed of my implementation but pointed out some missed optimizations that could improve memory usage, which I appreciated for its constructive critique.


Markdown supported