LRU cache with TTL
Your task
Implement a cache that combines LRU eviction with per-entry TTL. Process operations: ["put", now, key, value, ttl] inserts/updates key=value at time now, expiring at now+ttl (alive while query time < now+ttl), and marks it most-recently-used; ["get", now, key] returns the value if present and not expired (and marks it most-recently-used), else -1. Capacity is capacity: when a put would exceed capacity with a new key, first drop any currently-expired entries (as of now); if still over capacity, evict the least-recently-used live entry. A put that updates an existing key never triggers capacity eviction. Timestamps are non-decreasing. Return the list of get results in order. capacity is a positive integer.
Examples
lru_ttl_cache(capacity: int, ops: list[list]) -> list[int]Example 1
Input
lru_ttl_cache(2, [["put", 0, "a", 1, 100], ["put", 0, "b", 2, 100], ["get", 1, "a"], ["put", 1, "c", 3, 100], ["get", 2, "b"], ["get", 2, "c"]])Output
[1, -1, 3]