Implement an LFU Cache

Implement an LFU (Least Frequently Used) cache with:

  • get(key): return value if present and increment its frequency; otherwise return -1.
  • put(key, value): insert/update a key.
    • If key...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: