Implement a fixed-capacity LRU cache. The get method takes a key and returns the value or an indication that it's missing, the put method adds or updates a value, and on overflow the key that has gone unused the longest is evicted. Both operations must run in O(1).
~15 min by voice
How to approach it
They're checking whether you can combine two data structures: a hash table for O(1) lookup and a doubly linked list (or an ordered dictionary) for the usage order. It's also important to handle the edge cases carefully: updating an existing key, eviction, and a zero capacity.
The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.