FastPrepRecover a Function-Call LRU Cache with a Write-Ahead Log

Recover a Function-Call LRU Cache with a Write-Ahead Log

Anthropic logoAnthropic● HardFULLTIMEONSITE INTERVIEW

Problem statement

Simulate a function-call cache of positive capacity using least recently used eviction and an actual file-backed write-ahead log. Process operations in order and return one string for every operation.

Finite call adapter

A call row is ["CALL", functionId, resultValue, positionalCount, ...positionalArgs, keywordCount, key1, value1, ...]. Counts are decimal strings and each keyword name is unique within that call. Every argument and keyword value is a string. The opaque functionId identifies the supplied callable, positional arguments retain their order, and keyword dictionary insertion order does not affect identity.

The problem statement continues
Pro

Examples

Example 1

operations = [["CALL","f","A","1","x","0"],["CALL","f","A","1","x","0"],["RECOVER"],["CALL","f","A","1","x","0"]]capacity = 2return = ["VALUE:A|CALLS:1","VALUE:A|CALLS:1","RECOVERED:1|CALLS:1","VALUE:A|CALLS:1"]

The second call is a hit, and recovery reloads the same key without invoking the underlying function.

FastPrep Pro
Reported in 1 Anthropic interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See Anthropic hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Anthropic interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week