20%off off β€” LaunchSpecial
Exercises/#26 LRU Cache
#26

LRU Cache

MediumπŸ”— Linked Lists
110 XP

Problem

Design a data structure that follows the Least Recently Used (LRU) cache constraint. Implement get and put in O(1) time.

Examples

LRUCache(2) β†’ put(1,1) β†’ put(2,2) β†’ get(1)β†’1 β†’ put(3,3) β†’ get(2)β†’-1 (evicted) β†’ get(3)β†’3
linked-listhash-mapdesign
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

26 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features