A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L5
Problem
Implement LFUCache(capacity) with get(key) returning the value (or -1 if missing) and put(key, value). When capacity is exceeded, evict the least-frequently-used entry. Ties are broken by LRU. Test harness passes parallel ['method', args] sequences and expects the list of return values (None for put, value or -1 for get).
Summary
When storage is tight, something has to go.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.