Build an LRU Cache

hash map plus doubly linked list

Challenge 2 of Storage & CachingIntermediate~50 minFree

Build a least-recently-used cache with O(1) get and put, backed by a hash map and a doubly linked list. Add eviction at capacity, non-mutating peeks, and hit/miss statistics.

5 steps

  1. 1The Doubly Linked List
  2. 2get and put
  3. 3Eviction at Capacity
  4. 4Peek, Length, and Clear
  5. 5Hit / Miss Statistics
Start step 1