The Frequency Eviction
A hard Python mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L5
Interview Prompt
You're replaying a captured operation log against a fixed-capacity LFU cache to reproduce what each call returned. `run_lfu_cache(operations, args)` takes parallel lists where `operations[0]` builds the cache and each later call is a `get` or `put` with its arguments in `args[i]`; replay them against one instance and return each call's result, where a `get` yields the stored value or -1 when the key is absent and a `put` into a full cache first evicts the least-frequently-used key.
Summary
When storage is tight, something has to go.
How This Interview Works
- Read the vague prompt (just like a real interview)
- Ask clarifying questions to the AI interviewer
- Write your python solution with real code execution
- Get instant feedback and a hire/no-hire decision