Write pseudo code for an LFU Cache and explain how an LRU Cache works.
Asked in the Round 2 stage.
For the coding portion, implement lfu_cache(capacity, operations). Each operation is ['put', key, value] or ['get', key]. Return an array containing the result of each get, using -1 for a missing key. When full, evict the least frequently used key; break frequency ties by evicting the least recently used key.
def lfu_cache(capacity, operations):