InterviewLegend

Caches From Scratch

Alex Chen46 min readUpdated 43 real interview reports

An Anthropic cache round often starts with a one-line memoization import, and then the interviewer takes the import away. You rebuild the structure under it, and then the interviewer changes a rule that structure depends on. The base rebuild, an LRU from a hash map and a doubly linked list, is worked in Data Structures & Parsing. Each problem here starts where that one stops.

Two of the problems change the cache's rules. One has to survive a crash, and the other evicts by how often a key was used. Another gives you an LRU someone else wrote and asks what's wrong with it. The last two each take away a different library piece, the dict every other problem relies on and the plain string a text editor sits on, and ask you to build the replacement.

The Anthropic angle
These rounds check that you can back up the complexity claims you made earlier in the interviews. The crawler round ends on linear time in pages plus links, which assumes a visited-set lookup costs O(1). The LRU round assumes a reorder costs O(1). Taking away the dict or the ordered map checks that you can get those constants in code you wrote yourself. The cache problems also match serving work, where one long system prompt reused by thousands of requests should stay cached through a burst of one-off prompts. Once each rebuild runs, expect the interviewer to add a crash or a second thread.

AnthropicPremium lesson · Coding round

The 5 Anthropic problems are below.

  1. A Premium questionCoding · Medium
  2. A Premium questionCoding · Hard
  3. A Premium questionCoding · Medium

+ 2 more in this lesson

Each with hints, the follow-up and a tested solution.

Get the Anthropic questions

$49 a year · all 100 companies · cancel anytime

From 20,000+ candidate reports, forum threads behind logins and write-ups in Chinese.

Had your Anthropic interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Anthropic interview guide

Know what Anthropic asks before you walk in.

33 coding · 5 system design · 14 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.