xAI·Software Engineer·Technical Phone Screen
- Design and implement an LFU (least frequently used) cache class supporting get and put operations, both in O(1) time. On eviction, remove the least frequently used key, breaking ties by recency.
“I knew LRU cold but LFU tripped me up for a minute because the tie-breaking rule means you need to track both frequency AND insertion/access order within each frequency bucket.”