Fixed-Capacity Cache with Least-Recently-Used Eviction
Asked at Meta · Coding Questions · Difficulty: Medium · Last asked Jan 13, 2026
Build a key-value cache that holds at most `capacity` entries. When a new key arrives and the cache is already full, the cache throws out the entry that has gone the longest without being read or written (the least recently used one). Both reading and writing must take constant time on average, however large the cache is.
Loading the problem…
More Meta interview questions
- LLM conceptual questions
- Implement a Two-Hidden-Layer MLP with Backpropagation in NumPy
- Dot Product with Run-Length Encoded Vectors
- Count Lakes Wrapped by a Given Island
- Minimum Remove to Make Valid Parentheses
- LLM with Beam Search and Nucleus Sampling (Meta MSL)