hard

LRU Cache

DSA Practice
Description

LRU Cache

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the `LRUCache` class: - `LRUCache(capacity)` Initialize the LRU cache with positive size capacity. - `int get(key)` Return the value of the key if it exists, otherwise return -1. - `void put(key, value)` Update the value of the key if it exists. Otherwise, add the key-value pair to the cache. If the capacity is exceeded, evict the least recently used key.

Progress Tracker
Requirements
get and put must each run in O(1) average time complexity.
Use a combination of Hash Map and Doubly Linked List for optimal performance.
Maintain the order of access to track LRU.
Strategic Hints
Test Execution

Awaiting execution...