Search⌘ K
AI Features

LRU Cache

Explore how to implement an LRU cache data structure with set and get operations to efficiently manage storage by evicting the least recently used elements when capacity is reached.

Statement

Implement an LRU cache struct with the following functions:

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