LRU Cache

Implement an LRU (Least Recently Used) cache.

Design an LRUCache class:

  • LRUCache(capacity): Initialize the cache with a positive integer capacity.
  • get(key): Return the value associated...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: