Loading...
The Forgetful Machine
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- senior, staff
Problem
Implement an LRU (Least Recently Used) cache class with a fixed capacity. It should support get(key) returning the value or -1 if not present, and put(key, value) which inserts or updates. When capacity is exceeded, evict the least recently used key.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.