2dbi
Home/New Relic/Java Live Coding: LRU Cache With TTL
NNew Relic·DSAEngineerOnsite – Coding (Practical)

Java Live Coding: LRU Cache With TTL

Problem

Implement an LRU cache with per-entry TTL (reported New Relic Java live-coding round).

Example

get/put O(1); entries expire after TTL

Constraints

  • Concurrent access optional follow-up

Approach

Hash map + doubly linked list + lazy TTL on access.

added 6 days ago
LeadersAccount