Company: Dezerv
Difficulty: medium
LFU Cache Problem Description A cache is a limited storage that stores key-value pairs, implementing an eviction policy to manage its size. Least Frequently Used (LFU) cache removes the least frequently accessed key when the capacity is reached. You need to implement the Least Frequently Used (LFU) cache with the capacity N . You are also given Q operations of the following type: 1, key, -1 : Get the value of the key from the cache. If the value does not exist in the cache, return -1 . 2, key, value : Update the value of the key if present, or insert the key if not already present. When the cache reaches its capacity, it should invalidate and remove the least frequently used key before inserting a new item. For this problem, when there is a tie (two or more keys with the same frequency), the smallest key should be removed. For each operation of type 1, print the required value. Function description Complete the function solve() . This function takes the following 3 parameters and retur