This video is part of the Stack and Queue section under GFG SDE Sheet.
Design a data structure that works like a LRU Cache. Here cap denotes the capacity of the cache and Q denotes the number of queries. Query can be of two types:
The LRUCache class has two methods get() and set() which are defined as follows.
Example 1:
Input: cap = 2 Q = 2 Queries = SET 1 2 GET 1 Output: 2 Explanation: Cache Size = 2 SET 1 2 GET 1 SET 1 2 : 1 -> 2 GET 1 : Print the value corresponding to Key 1, ie 2.
Do check out:-
Problem: https://www.geeksforgeeks.org/problems/lru-cache/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/lru-cache-implementation/