CodingAbout 3 minutes · typed, no micFree drill · try as often as you like
Implement a least-recently-used cache with a fixed capacity. get(key) returns the value or -1, put(key, value) inserts or updates, and when the cache is full the least recently used entry is evicted. Both operations must be O(1).