LRU cache

A code exercise of about 20 minutes: read the statement, solve «LRU cache» in the browser and get a review like in a real interview.

Code · 20 min
Loading…

Statement

Implement the class LRUCache(capacity) with get(key) (returns the value or undefined) and put(key, value). When full, put of a new key evicts the least recently used one. Both get and put count as use. Both operations must be O(1).