LRU Cache
Design an LRU Cache with O(1) get and put operations. Think about: What data structures enable O(1) access and ordering? Hint: Combine a hash map with a doubly linked list. Example: LRUCache(2) put(1, 1), put(2, 2) get(1) → 1 put(3, 3) # evicts key 2 get(2) → -1
Design a cache that evicts the least recently used item when full. It's one of the few problems that tests both data structure intuition and clean API design. Interviewers love it because it reveals whether you can combine a hash map with a linked list to get O(1) operations. This pattern shows up constantly in systems design.

Meet Coco
Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.