Product
Pricing
Blog
Forum
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
AI Insights
Quick Summary
Design a cache that stores key-value pairs with associated weights and enforces a strict maximum total weight limit.
When capacity is exceeded, automatically evict the item with the highest weight first.
Support efficient lookups and handle key updates that may trigger immediate evictions.
What This Tests
Efficient priority-based eviction using a max-heap
Constant-time key lookups and state tracking with a hash map
Synchronizing multiple data structures during updates
Handling edge cases like a single item exceeding the total capacity
Common Patterns
Heap / Priority Queue
Hashing
Greedy
Collapse
Hint 1
Hint 2
What Interviewers May Ask Next
Report
Report seen similar question in interview
Accepted
1.8k
/3.4k
Acceptance Rate
53.0%
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
Python3
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected