Company: Ethos_2march

Difficulty: medium

Problem Statement

LFU Cache Problem Description Build a Least Frequently Used (LFU) cache holding at most cacheSize key-value pairs, supporting two operations, GET and PUT. A GET operation looks up the value stored under a given key. If that key currently exists in the cache, its value is returned. If not, -1 is returned instead. A PUT operation inserts a new key-value pair or overwrites an existing one. Once the cache is at capacity, the entry used least often is evicted to make room for the incoming pair. Should more than one entry share the lowest usage frequency, the one that was accessed the longest time ago among them is evicted. 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,

More Ethos_2march OA questionsInterview experiences