← Questions

LFU cache

0
xAICodingLast asked Jul 2025

Implement a least-frequently-used cache with get and put in O(1). When full, evict the key used least often, breaking ties by least recently used. Keep a map from key to node and a map from frequency to a list of keys, and track the minimum frequency.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding