LRU Cache

Design and implement an LRU (Least Recently Used) cache.

Supported operations:

  • get key: return the value if the key exists and mark it as most recently used; otherwise return -1.
  • `put key value...

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: