How to Implement an O(1) LRU Cache Using a Doubly Linked List and Hash Map
An O(1) Least Recently Used (LRU) cache pairs a hash map (mapping keys to node pointers for O(1) lookup) with a doubly linked list bounded by dummy head and tail sentinels (enabling O(1) node splice and insertion at the MRU front). On every get(key) or put(key, val), the accessed node is unlinked and moved immediately after head; when capacity is exceeded, head's opposite sentinel (tail.prev) is evicted in O(1).

