Cache Design Playground
Cache Design Playground
HardSystem Design66% accepted
Implement a small LRU cache simulator and print the final order of keys from most recent to least recent.
Approach
Simulate an LRU cache of the given capacity over PUT key value / GET key operations. After ALL operations, print the keys still in the cache, most-recently-used first, space-separated (print EMPTY if none). First line: capacity and operation count.
Input
2 5
PUT 1 10
PUT 2 20
GET 1
PUT 3 30
GET 2
Output
3 1
More System Design problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards