Implement an LRUCache class with a given capacity and two methods: get returns the value for a key or None, and put stores a value. When the cache overflows, the key that hasn't been accessed for the longest time is evicted, and both operations must run in O(1).
~15 min by voice
How to approach it
They're checking whether you can combine a hash table with an ordered structure to get O(1) get and put, and whether you handle the edge cases carefully: refreshing a key on get, updating an existing key without eviction, a missing key.
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.