PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Oracle

Implement an LRU cache

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of data structures and algorithmic design for caching and eviction policies, focusing on achieving efficient operations under strict time-complexity constraints.

  • medium
  • Oracle
  • Coding & Algorithms
  • Software Engineer

Implement an LRU cache

Company: Oracle

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Design and implement a data structure for a Least Recently Used (LRU) cache with a fixed capacity. The cache must support: - `get(key)`: return the value for `key` if present; otherwise return `-1`. This operation marks the key as most-recently-used. - `put(key, value)`: insert or update the value for `key`. This operation marks the key as most-recently-used. If inserting causes the cache to exceed capacity, evict the least-recently-used key. Constraints: - Aim for average O(1) time per operation. - Use standard in-memory data structures (no external databases).

Quick Answer: This question evaluates understanding of data structures and algorithmic design for caching and eviction policies, focusing on achieving efficient operations under strict time-complexity constraints.

Related Interview Questions

  • Solve Five Coding Problems - Oracle (medium)
  • Compute letter frequencies from encoded string - Oracle (medium)
  • Count closed islands in a grid - Oracle (easy)
  • Implement in-memory data structures and booking API - Oracle (hard)
  • Return a valid course completion order - Oracle (medium)
Oracle logo
Oracle
Jan 26, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
3
0

Design and implement a data structure for a Least Recently Used (LRU) cache with a fixed capacity.

The cache must support:

  • get(key) : return the value for key if present; otherwise return -1 . This operation marks the key as most-recently-used.
  • put(key, value) : insert or update the value for key . This operation marks the key as most-recently-used. If inserting causes the cache to exceed capacity, evict the least-recently-used key.

Constraints:

  • Aim for average O(1) time per operation.
  • Use standard in-memory data structures (no external databases).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Oracle•More Software Engineer•Oracle Software Engineer•Oracle 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.