(This question is a variation of LeetCode 146. LRU Cache. If you're not familiar with it, it's recommended to complete that problem first.)
Implement a data structure that processes a series of incoming key-value pairs with a timestamp, and allows querying pairs within a specified time window. Assume the minimal time unit for all operations is one minute.
Implement the WindowedKeyValueStore class:
WindowedKeyValueStore(int capacity, int windowSize): Initialize the cache with positive sizecapacityandwindowSize.void put(int key, int val, int time): Update the time and value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected