Back to DSA sheet

LRU Cache

MediumLinked List
Open on LeetCodeAmazonGoogleMeta

Design a cache with a capacity that supports get and put in O(1), evicting the least recently used key when full.

Constraints
  • 1 <= capacity <= 3000
  • At most 2 * 10^5 calls
Sheets
Blind 75Grind 75NeetCode 150NeetCode 250
lru-cache.cpp
Loading editor
Custom input (stdin)
Output

Run your code to see its output.