Back to problems

LRU + LFU + Custom Eviction Function

Object-Oriented Programming · Citadel · Medium

Requirements Complete the following phases consecutively. Build an LRU cache supporting get(key) and put(key, value). With a fixed capacity, both operations should run in O(1) amortized time. Extend the design to an LFU cache with the same interface. When space is needed, remove the entry used the fewest times. If several entries have equal frequency, remove the least recently used one among them. Create a custom eviction version by injecting the eviction policy through a…

Checking your access…