Practice / Software

LRU cache

Medium · Coding (typed)

Implement an LRU (least recently used) cache with a fixed capacity: get(key) returns the value or -1, put(key, value) inserts or updates. When full, evict the least recently used key. Both operations must be O(1).

Create a free account to answer it and get scored on what a strong answer covers.