DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Eviction Policy

A medium Python mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.

Domain
Python
Difficulty
medium
Seniority
L4

Interview Prompt

A read-through cache sits in front of a slow store and holds at most a fixed number of entries; once it is full, the entry that has gone longest without being touched is dropped to make room for a new one. Replay `operations` against such a cache and return one result per operation, in order. `operations[0]` is always `['LRUCache', capacity]`, which sets the entry limit (`capacity` is at least 1); each later operation is either `['put', key, value]`, which inserts or overwrites a key, or `['get', key]`, which returns that key's value or -1 when the key is absent. Both reading and writing a key count as touching it, so the next eviction removes whatever key has stayed idle longest. The constructor and every `put` contribute `None` to the result list; each `get` contributes the value it found, or -1.

Summary

Fixed capacity. The key left idle longest is the one that goes.

How This Interview Works

  1. Read the vague prompt (just like a real interview)
  2. Ask clarifying questions to the AI interviewer
  3. Write your python solution with real code execution
  4. Get instant feedback and a hire/no-hire decision

Related

  • All Mock Interviews
  • Practice Mode (untimed)
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Practice Problems
  • Daily Challenge