hard+350 XPFrontend AlgoArena
LRU (Least Recently Used) Cache
Implement LRUCache(capacity) with .get(key) and .put(key, value) methods.
What it has to do
.get(key)returns value or -1 if absent, marking key as recently used..put(key, value)inserts or updates value. Evicts least recently used item when capacity is exceeded.
Your workspace
Try it yourself· Edit the code, then press Run
Loading playground...
Ready to check it?
1 tests run against your code, right here in your browser. Sign in to claim the XP when you pass.
AI Crack & Solution Assist
Stuck? Get instant AI hints or break down the optimal solution.