Company: Media.net IIT BHU
Difficulty: medium
LRU Cache Problem Description Build a fixed-size cache that throws away its least recently used entry whenever it overflows. The cache supports three operations: LRUCache(capacity) -- create an empty cache that holds at most capacity entries. This is always the first operation and happens exactly once. put(key, value) -- store value under key . If key is already present its value is replaced. If storing a new key would take the cache past its capacity, the entry that was used least recently is removed first. get(key) -- return the value stored under key , or -1 if the cache does not hold it. Both get and put count as using a key, whether or not the key was already present and whether or not get found anything. The least recently used entry is the one whose last successful get or put is furthest in the past. Input Format Two lines, in the serialised form used by the original question: Line 1: the list of operation names, for example ["LRUCache","put","get"] . Line 2: the matching list o