Back to problems

Implement TTL Cache and Tree Balance Reporting

Object-Oriented Programming · Netflix · Medium

Task A: Time-Limited Cache Simulator Min-Heap with Versioned Overwrite Detection The core observation is that expired keys do not need to be scanned one by one from the main dictionary. Instead, we keep a min-heap ordered by expiration time. The earliest-expiring key is always at the root, so cleanup can pop from the heap until the root is still alive. This avoids repeatedly checking every key on a count call. A second problem appears when a key is overwritten. The old heap…

Checking your access…