LeetCode 146: LRU Cache Design with O(1) Hash Map + Doubly Linked List
Subtitle / Summary This is not a memorization question. It is core cache-engineering practice: satisfy fast lookup and least-recently-used eviction at the same time, both in constant average time. We derive the optimal structure from naive approaches and provide runnable implementations. Reading time: 14-18 min Tags: LRU, hash map, doubly linked list, system design SEO keywords: LRU Cache, LeetCode 146, hash map, doubly linked list, O(1) Meta description: Build an LRU cache with hash map + doubly linked list to achieve O(1) average get/put, with engineering use cases, pitfalls, and six-language implementations. Target Readers LeetCode learners who want to master data-structure composition Backend/middleware engineers implementing local caches Interview candidates who know the answer headline but not the invariants Background / Motivation Caching trades space for time, but cache space is limited. When full, we must evict keys. LRU (Least Recently Used) assumes: ...