Search⌘ K
AI Features

LRU Cache

Understand the principles of an LRU cache and learn to implement it with set, get, and eviction methods. This lesson helps you build a cache that maintains limited capacity by removing the least recently used items first, improving data retrieval efficiency.

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
...