35. Classify Cache Lookups
EasyCaches and indexing
Each cache entry is [key, written_at, ttl]. Each lookup is [key, time]. Entries are independent and never change during this batch.
Return fresh if the key exists and written_at ≤ time < written_at + ttl, stale if the key exists but is outside that interval, or missing if the key has no entry. Return labels in lookup order.
Example 1
Input: entries = [["card",3,4]], lookups = [["card",3],["card",6],["card",7],["card",2],["other",5]] Output: ["fresh","fresh","stale","stale","missing"]
Example 2
Input: entries = [["hold",8,0]], lookups = [["hold",8],["unknown",0]] Output: ["stale","missing"]
Constraints
At most 100,000 entries and 100,000 lookups. Entry keys are unique.Times and TTLs are integers in [0, 10⁹]. A TTL of zero gives an empty fresh interval.