As reported: Arista Networks online assessment (2026), coding question 1 — exactly LeetCode 460.
This is LeetCode 460 — LFU Cache.
Implement LFUCache:
LFUCache(capacity)— a cache holding at mostcapacitykeys.get(key)— the value ofkeyif present, else-1.put(key, value)— insert or update the key. When the cache is full, first evict the least frequently used key; if several keys share the lowest use count, evict the least recently used of them.
The use counter of a key is the number of get and put calls on it since it was inserted (a new key starts at 1). Both operations must run in O(1) average time.
Example
["LFUCache","put","put","get","put","get","get","put","get","get","get"]
[[2],[1,1],[2,2],[1],[3,3],[2],[3],[4,4],[1],[3],[4]]
-> [null,null,null,1,null,-1,3,null,-1,3,4]
Constraints: 1 ≤ capacity ≤ 10^4; 0 ≤ key ≤ 10^5; 0 ≤ value ≤ 10^9; at most 2·10^5 calls.
Code runner format: LeetCode's design format — line 1 the method names, line 2 their arguments. Implement the LFUCache class; the harness prints the list of results.