Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
The cache supports two operations:
get(key): Return the value ofkeyif it exists, otherwise return-1.put(key, value): Update the value ofkeyif it exists. Otherwise, add the (key, value) pair to the cache. If inserting causes the cache to exceed its capacity, evict the least recently used key.
Both operations must run in O(1) average time.
For the auto-grader: implement a single function lruCacheOps(capacity, operations) that returns the result of each operation in order. Each operation is one of:
["put", key, value]→ returnsnull(usenullin JavaScript /Nonein Python).["get", key]→ returns the value or-1.