MEDIUMasked at 109 companies

LRU Cache

A medium-tier problem at 45% community acceptance, tagged with Hash Table, Linked List, Design. Reported in interviews at AppFolio and 108 others.

Founder's read

LRU Cache is the design problem that separates candidates who understand data structures from those who just memorize solutions. It's asked by over 100 companies across FAANG, fintech, and infrastructure roles, including Apple, ByteDance, and Disney. The problem asks you to build a cache that evicts the least recently used item when full. The acceptance rate sits at 45%, which means nearly half the people who attempt it on an assessment blank or time out. If you hit this during a live OA and the doubly-linked list implementation isn't clicking, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
109
Difficulty
MEDIUM
Acceptance
45%

Companies that ask "LRU Cache"

If this hits your live OA

LRU Cache is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The trap is obvious: you need O(1) get and O(1) put. A hash map alone gets you get in O(1), but put requires knowing which item to evict, and finding the least recently used takes O(n) without auxiliary structure. The real trick is pairing the hash map with a doubly-linked list. The list maintains insertion order, the head is always the oldest, the tail is always the newest. On get, you move the accessed node to the tail. On put, if capacity is hit, you remove from the head. Most candidates see 'Hash Table' and 'Linked List' as separate topics; the hard part is wiring them together cleanly so updates don't break invariants. StealthCoder is the hedge when the pointer manipulation goes sideways during screen share.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

LRU Cache recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

LRU Cache interview FAQ

Is LRU Cache still heavily asked at top companies?+

Yes. Over 100 companies report asking it, including Apple, ByteDance, and Disney. It's a standard design tier problem in system-design prep and medium-level OAs. Don't skip it thinking it's outdated. It appears across infrastructure, backend, and full-stack roles.

What's the trick I'm missing if I can't get it to O(1)?+

You need both a hash map and a doubly-linked list. The map gives you O(1) key lookup. The doubly-linked list maintains recency order and lets you remove arbitrary nodes in O(1). Most people try to use only one. The pattern is: map stores key to node pointer, list maintains access order.

Why is the acceptance rate only 45% if it's a classic problem?+

Because pointer manipulation and state consistency are error-prone under live-test pressure. Off-by-one errors, forgetting to update pointers on both directions, and losing track of capacity checks are common. The algorithm is straightforward; the implementation is where candidates trip up.

How does doubly-linked list choice relate to the hash table topic?+

Hash table is the retrieval layer. Doubly-linked list is the eviction layer. Together they're a compound data structure. Singly-linked list doesn't work because removing an arbitrary node still requires traversal. Doubly-linked list gives you O(1) removal via pointer manipulation.

What's the most common mistake on the put operation?+

Forgetting to handle the case where a key already exists in the cache. You must update its value and move it to the tail as the most recently used, not just overwrite it. Also easy to forget decrementing size when you update an existing key instead of adding a new one.

Want the actual problem statement? View "LRU Cache" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.