#146

LRU Cache

medium· Linked Listruns: 0

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement LRUCache with a positive integer capacity, supporting get(key) returning the value (or -1 if absent) and put(key, value) inserting or updating, evicting the least recently used key when the capacity is exceeded. Both operations must run in O(1) average time.

sign in to paste and practice your own solution
desktop only

codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.

you can still browse problems and sections from your phone.