PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Microsoft

Implement cache and merge intervals

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in designing and implementing efficient data structures (a fixed-capacity LRU key-value cache) and interval-processing algorithms (merging overlapping closed intervals), emphasizing time-complexity constraints, correct state management, and robustness to edge cases within the Coding & Algorithms category.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Machine Learning Engineer

Implement cache and merge intervals

Company: Microsoft

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

The interview included two coding tasks: 1. Implement a fixed-capacity key-value cache with `get(key)` and `put(key, value)`. Both operations must run in O(1) average time. When the cache is full and a new key is inserted, evict the least recently used entry. A successful `get` also counts as a use. 2. Given a list of closed intervals `[start, end]`, merge all overlapping intervals and return the resulting non-overlapping intervals sorted by start value.

Quick Answer: This question evaluates proficiency in designing and implementing efficient data structures (a fixed-capacity LRU key-value cache) and interval-processing algorithms (merging overlapping closed intervals), emphasizing time-complexity constraints, correct state management, and robustness to edge cases within the Coding & Algorithms category.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Feb 23, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
2
0
Loading...

The interview included two coding tasks:

  1. Implement a fixed-capacity key-value cache with get(key) and put(key, value) . Both operations must run in O(1) average time. When the cache is full and a new key is inserted, evict the least recently used entry. A successful get also counts as a use.
  2. Given a list of closed intervals [start, end] , merge all overlapping intervals and return the resulting non-overlapping intervals sorted by start value.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Machine Learning Engineer•Microsoft Machine Learning Engineer•Microsoft Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ 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.