Implement an LFU (least frequently used) cache.
Asked in the Coding stage. Senior research engineer loop; the candidate implemented set assuming doubly-linked-list APIs.
Implement lfu_cache(capacity, operations). Each operation is ['put', key, value] or ['get', key]. Return a list containing the result of every get, using -1 for a missing key. A put on an existing key updates its value and increases its frequency. When full, evict the least frequently used key; break ties by evicting the least recently used key.
def lfu_cache(capacity, operations):