Katkat

Implement LRU cache with O(1) ops

AmazonSoftware Engineer · Onsite

Last updated

This interview question evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer for Implement LRU cache with O(1) ops states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Design and implement a fixed-capacity cache supporting get(key) -> value and put(key, value) in O(

  1. average time. When capacity is reached, evict the least recently used entry. Specify how recency is updated on get and put, how updates to existing keys are handled, what to return for missing keys, and discuss thread-safety options and testing strategy.