Engrain by ByteRush

JS.16.03 Mid-levelCore — asked often

LRU cache

Comes up in: Coding, DSA

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • O(1) get/put with Map insertion order
  • doubly linked list + hash map version
  • capacity eviction
  • TTL variant

Words you will know

LRUeviction policy

What you will practise

  • implement both versions

Interview questions this answers

  • Implement an LRU cache with O(1) operations.
  • Implement get(obj, "a.b[0].c", defaultValue).