Reported interview periodFeb 2026
Weighted LRU Cache
Build an LRU cache whose capacity is the total weight of stored entries rather than the number of keys.
Practice focusget returns -1 when absent and marks a hit most-recently used. put inserts or replaces a key. On replacement, remove the old weight before checking capacity. Evict least-recently used entries until the new value fits; one insertion may evict several entries. A non-positive size or a size exceeding capacity raises ValueError without changing the cache. Exact fits are valid. Target average O(1) time for get and for each individual insert, update, or eviction. The provided run case owns fixture dispatch and is not candidate work.…