LFU Cache

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

Design an LFU (least-frequently-used) cache with `get(key)` (returns value or -1, increases the key's frequency) and `put(key, value)`. When at capacity, evict the least-frequently-used key, breaking ties by earliest insertion (FIFO).

Loading the problem…