LRU Cache
Medium · Phone screen · Onsite · Full-time
The pair programming question was to implement an LRU cache. I had to support the usual get and put behavior, and evict the least recently used item once the cache hit capacity. The interviewer cared about whether the code was clean and actually usable, not just whether I knew the textbook answer. I used a hash map with a linked list to track ordering, though an OrderedDict in Python would work too. After the implementation we spent some time testing the behavior and making sure edge cases were handled.
