0 day streak
Anonymous · shared experience1 Oct 2025 · 4 views

BlackRock: Design a cache that supports LRU and LFU eviction

Interview question #BlackRock SDE 2 Low-level design

Problem. Design a cache system for an Associate-level C++ role.

Follow-up. How would you implement LRU (evict the least recently used entry) and LFU (evict the least frequently used entry) inside the same design?

What to prepare. An eviction policy interface so the cache can swap strategies. LRU with a hash map plus a doubly linked list. LFU with a map from frequency to a list of keys and a running minimum frequency, so both get and put stay O(1).

0 comments

Comments 0

No comments yet. Ask the author something, or add what happened in your own round.