LRU Cache

Design and implement an LRU (Least Recently Used) cache supporting:

  • get(key): return the value if the key exists and mark it as most recently used, otherwise return -1.
  • put(key, value): insert...

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: