Search⌘ K
AI Features

LRU Cache

Understand how to implement an LRU cache that supports initialization, updating, and retrieving key-value pairs. Learn the eviction policy that removes the least recently used items to maintain cache capacity efficiently.

Statement

Implement an LRU cache class with the following functions:

  • Init(capacity): Initializes an LRU cache with the capacity size.
  • Set(key, value): Adds a new key-value pair or updates
...