FrontendX
LFU Cache Design
medium
Description
AI Assistance
Solution
Test Cases
Test Result
Submissions
Canvas
LFU Cache
Design
Design LFU cache using hashmap and frequency tracking.
Examples
Example 1
Input:
[1,2,3]
Output:
[-1,-1,-1]
Example 2
Input:
[1,2,3]
Output:
[-1,-1,-1]
Hints
Hint 1
Use two HashMaps: key->(value, freq), and freq->ordered keys.
Hint 2
Maintain minimum frequency.
Hint 3
On access, increment freq and move in the freq map.
LFU Cache Design
Design LFU cache using hashmap and frequency tracking.