The Allstate Claims experience processes session text and repeatedly accesses recently used session values. Implement both of the following algorithms:
get and put in O(1) average time.Create a solve function that returns the substring result and executes a sequence of cache operations. A cache get returns the stored value or -1 when the key is absent. A successful get, and every put, marks the key as most recently used. When capacity is exceeded, evict the least recently used key.
s is a string and may contain any Python characters.capacity is a positive integer.operations is a list of lists. Each operation is either ['put', key, value] or ['get', key], where keys and values are integers.longest_length, an integer, and cache_results, a list containing the result of each get operation in order.def solve(s, capacity, operations):