PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Merge overlapping intervals

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in interval manipulation, array-based data structures, algorithm design, and time/space complexity analysis, focusing on merging overlapping numeric ranges into non-overlapping sorted intervals.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Merge overlapping intervals

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given an array of intervals, where each interval is represented as a pair of integers [start, end] with start <= end. The intervals may be unsorted and may overlap. Task: - Merge all overlapping intervals. - Return a new array of non-overlapping intervals that cover exactly the same ranges as the input. - The result should be sorted in ascending order by interval start. Example: - Input: [[1,3], [2,6], [8,10], [15,18]] - Output: [[1,6], [8,10], [15,18]] Constraints (you may assume reasonable values if not specified by the interviewer): - 1 <= number of intervals <= 10^4 - Interval endpoints are integers in a range such as [-10^9, 10^9]. Design an algorithm to perform this merge efficiently and discuss its time and space complexity.

Quick Answer: This question evaluates proficiency in interval manipulation, array-based data structures, algorithm design, and time/space complexity analysis, focusing on merging overlapping numeric ranges into non-overlapping sorted intervals.

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
Nov 19, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

You are given an array of intervals, where each interval is represented as a pair of integers [start, end] with start <= end. The intervals may be unsorted and may overlap.

Task:

  • Merge all overlapping intervals.
  • Return a new array of non-overlapping intervals that cover exactly the same ranges as the input.
  • The result should be sorted in ascending order by interval start.

Example:

  • Input: [[1,3], [2,6], [8,10], [15,18]]
  • Output: [[1,6], [8,10], [15,18]]

Constraints (you may assume reasonable values if not specified by the interviewer):

  • 1 <= number of intervals <= 10^4
  • Interval endpoints are integers in a range such as [-10^9, 10^9].

Design an algorithm to perform this merge efficiently and discuss its time and space complexity.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

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