get(key)
, check if the key exists in the cache. If not, return -1. If it does, increment the frequency, update the minimum frequency if needed, and return the value.put(key, value)
, if the key exists, update the value and frequency. If the cache is at capacity, remove the least frequently and least recently used key. Insert the new key with frequency 1.minf
as needed.