AdvancedJavaScript
Implement a LRU Cache
Implement a data structure for a Least Recently Used (LRU) cache. It should support get and put operations with O(1) time complexity.
Examples
Input: const lruCache = new LRUCache(2); lruCache.put(1, 1); lruCache.put(2, 2); lruCache.get(1); lruCache.put(3, 3); lruCache.get(2);
Output: -1
Your Solution
Output
Click 'Run Code' to see the output