#include <iostream>
#include <vector>
#include <list>
#include <unordered_map>
#include <unordered_set>
using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// LFU - Least Frequently Used
class FreqNode{
public:
int freq;
// We use a SET in lieu of a linked list for storing elements with the same access frequency
// for simplicitly of implementation.
// HASH SET structure which holds the keys of such elements that have the same access frequency.
// Its insertion, lookup and deletion runtime complexity is O(1).
unordered_set<int> items;
FreqNode(int f){
this->freq = f;
}
};
// LFU - Least Frequently Used Cache Algorithm
// 1 Linked List + 1 Set + 1 Hash
// O(1) for all: Insert, Delete and Lookup
class LFUCache{
public:
list<FreqNode*> freqNodes;