Implement a Least Frequently Used (LFU) cache.
HardProblem Statement
Implement a Least Frequently Used (LFU) cache.
Sample Input
Capacity: 3; Operations: Put(1, "A"), Put(2, "B"), Put(3, "C"), Get(1), Put(4, "D")
Sample Output
Get(1): A Cache: 1: A 4: D 3: C
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
using System;
using System.Collections.Generic;
class LFUCache
{
static void Main()
{
// Implement a Least Frequently Used (LFU) cache
}
}
Input
Capacity: 3; Operations: Put(1, "A"), Put(2, "B"), Put(3, "C"), Get(1), Put(4, "D")
Expected Output
Get(1): A Cache: 1: A 4: D 3: C