Back to exercises

LRU Cache

Store items in an OrderedDict, move keys to the end whenever they are read or updated, and evict the oldest item when capacity is exceeded.

Coding Exercises Medium O(1)

LRU Cache

Store items in an OrderedDict, move keys to the end whenever they are read or updated, and evict the oldest item when capacity is exceeded.

Implement an LRU cache with O(1) get and put operations.