Back to problems

LFU Cache

Object-Oriented Programming · Apple · Hard

LFU Cache Create a data structure that behaves as a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Creates a cache with the specified positive capacity. int get(int key) Retrieves the value associated with key when it exists; otherwise, it returns -1. void put(int key, int value) Replaces the value when key is already present or adds the key-value pair when it is absent. If the cache has reached its capacity, remove the least…

Checking your access…