PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Bloomberg

Design variable-size LRU cache

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of cache design and eviction policies (LRU), management of variable-sized entries and memory budgeting, and the implementation of efficient data structures that support amortized O(1) access, updates and correct capacity accounting.

  • Medium
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Design variable-size LRU cache

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Implement an in-memory cache with least-recently-used eviction where each entry has a variable size in bytes. The cache exposes set(key, value, size), get(key), delete(key), and resize(newCapacity). The cache capacity is a byte budget; inserting or resizing must evict least-recently-used entries until the total size is <= capacity. Accessing or updating an entry refreshes its recency. Updates to an existing key replace the value and size atomically. Reject inserts whose single entry size exceeds the capacity. Aim for O( 1) amortized time for get, set (excluding evictions) and O(n) space. Provide unit tests covering: updates that shrink/expand size, eviction order after mixed gets/sets, deletion of head/tail, and behavior when capacity is reduced below current usage.

Quick Answer: This question evaluates understanding of cache design and eviction policies (LRU), management of variable-sized entries and memory budgeting, and the implementation of efficient data structures that support amortized O(1) access, updates and correct capacity accounting.

Related Interview Questions

  • Minimize Travel Assignment Cost - Bloomberg (medium)
  • Determine Balloon Popping Time - Bloomberg (medium)
  • Solve meeting and tree problems - Bloomberg (easy)
  • Minimize travel cost with two cities - Bloomberg (easy)
  • Check connectivity between two subway stations - Bloomberg (easy)
Bloomberg logo
Bloomberg
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
7
0

Implement an in-memory cache with least-recently-used eviction where each entry has a variable size in bytes. The cache exposes set(key, value, size), get(key), delete(key), and resize(newCapacity). The cache capacity is a byte budget; inserting or resizing must evict least-recently-used entries until the total size is <= capacity. Accessing or updating an entry refreshes its recency. Updates to an existing key replace the value and size atomically. Reject inserts whose single entry size exceeds the capacity. Aim for O(

  1. amortized time for get, set (excluding evictions) and O(n) space. Provide unit tests covering: updates that shrink/expand size, eviction order after mixed gets/sets, deletion of head/tail, and behavior when capacity is reduced below current usage.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

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