LRU + LFU + Custom Eviction Function

Asked at Citadel · Coding Questions · Difficulty: Hard · Last asked Jan 25, 2026

Build a fixed-capacity key-value cache in three steps: first with a least-recently-used eviction rule, then with a least-frequently-used rule, and finally as one cache class whose eviction rule is supplied from outside as a policy object. Keys and values are integers; every operation below must run in `O(1)` amortized time.

Loading the problem…