Frequency-Based Eviction Cache

Asked at LinkedIn · Coding Questions · Difficulty: Hard · Last asked Apr 17, 2026

Build a fixed-capacity key-value cache. Every key keeps a use count: each read or write of the key adds one. When the cache is full and a new key must be stored, the cache drops the entry that has been used the fewest times, and among entries with that same count, the one whose last use is oldest.

Loading the problem…