Loading...

The Frequency Eviction

A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
hard
Seniority
senior, staff

Problem

A content delivery system needs a cache that evicts the least frequently accessed item when full. Items accessed the same number of times should be evicted in least-recently-used order. Implement an LFU cache with get and put operations, both in O(1) amortized time.

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.