Python data engineering interview problem. Difficulty: advanced. Pattern: Hashing. About 20 minutes. Part of the Pro drill bank.
A hot key-value cache for SKU lookups should evict the least recently used entry when it hits capacity, the same policy as many production caches.
Simulate an LRU cache: get/put operations with a capacity, returning the state the tests expect.
Input: lru_run(2, [['put', 1, 'a'], ['put', 2, 'b'], ['get', 1], ['put', 3, 'c'], ['get', 2], ['get', 3]]) Output: ['a', None, 'c'] This input follows the stated rules and produces this output.
Topics: lakebench, python, OOP.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Implement a fixed-capacity cache that evicts the least recently accessed key.
Simulate an LRU cache: get/put operations with a capacity, returning the state the tests expect.