PayPay India services may cache frequently requested values while evicting entries that are used least often. Implement a least commonly used (LCU) cache with O(1) average-time insertion, retrieval, update, and removal.
Each cache entry has a usage frequency. A successful get and every put increase that entry's frequency by one. When the cache is full, evict the entry with the smallest frequency. If multiple entries have the same frequency, evict the least recently used entry among them.
Implement simulate_lcu(capacity, operations). Each operation is one of the following:
['put', key, value]: Insert or update an entry. Return None.['get', key]: Return the value, or -1 if the key does not exist.['remove', key]: Remove the entry and return True, or return False if it does not exist.Keys are integers and values are integers. The returned list must contain one result for every operation, in order.
def simulate_lcu(capacity, operations):