PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Disney

Implement an LRU cache

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of data structures and algorithmic optimization for constant-time cache operations, with emphasis on cache eviction policies and state management.

  • medium
  • Disney
  • Coding & Algorithms
  • Software Engineer

Implement an LRU cache

Company: Disney

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## LRU Cache Design and implement a fixed-capacity **Least Recently Used (LRU)** cache. ### Operations - `get(key) -> value | -1/null`: Return the value if present; otherwise indicate missing. Accessing a key makes it **most recently used**. - `put(key, value)`: Insert or update the value. Updating also makes it **most recently used**. ### Eviction rule - When inserting causes the cache to exceed capacity, evict the **least recently used** item. ### Requirements - Target time complexity: `O(1)` average for both `get` and `put`. ### Input/Output format You may choose an interface/class-based implementation (common in interviews). Clearly define how missing keys are represented (e.g., `-1` for integers).

Quick Answer: This question evaluates understanding of data structures and algorithmic optimization for constant-time cache operations, with emphasis on cache eviction policies and state management.

Related Interview Questions

  • Filter ads by a single rule - Disney (medium)
  • Determine if chasing points will meet - Disney (medium)
  • Solve matrix add, frequency count, longest consecutive - Disney (Medium)
  • Solve grid shortest path with BFS - Disney (Medium)
  • Implement BFS shortest path in grid - Disney (Medium)
Disney logo
Disney
Jan 22, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
4
0
Loading...

LRU Cache

Design and implement a fixed-capacity Least Recently Used (LRU) cache.

Operations

  • get(key) -> value | -1/null : Return the value if present; otherwise indicate missing. Accessing a key makes it most recently used .
  • put(key, value) : Insert or update the value. Updating also makes it most recently used .

Eviction rule

  • When inserting causes the cache to exceed capacity, evict the least recently used item.

Requirements

  • Target time complexity: O(1) average for both get and put .

Input/Output format

You may choose an interface/class-based implementation (common in interviews). Clearly define how missing keys are represented (e.g., -1 for integers).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Disney•More Software Engineer•Disney Software Engineer•Disney Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.