Company: Ethos_2march
Difficulty: medium
LFU Cache Problem Description Implement a Least Frequently Used (LFU) cache data structure of size cacheSize that handles two types of queries, GET and PUT. A GET query attempts to retrieve the value of a given key. If the key is present in the cache, it is returned. Otherwise, it returns -1. A PUT query updates or inserts a key-value pair into the cache. When the cache is full, the least frequently used key is removed to accommodate the new key-value pair. If there is a tie in the frequency of keys, then the least recently used key is removed. Return an array of integers where each i th element is the answer for the i th GET query. #include <bits/stdc++.h> /* * Complete the 'implementLFU' function below. * * The function is expected to return an INTEGER_ARRAY. * The function accepts the following parameters: * 1. INTEGER cacheSize * 2. STRING_ARRAY queries */ vector<int> implementLFU(int cacheSize, vector<string> queries) { } int main() { } Examples Example 1: Input: