Verified interview challenge
Build a weighted LRU cache
Manage a cache whose capacity depends on entry size rather than the number of keys.
Unlock with Full AccessThe challenge
Reads and writes update recency, while inserting or replacing a value changes the total stored size. One insertion may need to evict several older entries. Keep size accounting and recency consistent through replacements, missing reads and exact-capacity cases without scanning the whole cache for each operation.
What you'll practise
Capacity accounting
Remove an entry's previous contribution before applying its replacement.
Recency and eviction
Preserve the required order while making enough space for a new value.
# Your implementation goes here
# Run examples and inspect results
# Full starter code includedRun your code to see results.