PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Apple

Merge overlapping time intervals

Last updated: Mar 29, 2026

Quick Overview

This question evaluates competence in interval and array manipulation, sorting-based algorithm design, overlap detection, and efficient time/space complexity reasoning.

  • medium
  • Apple
  • Coding & Algorithms
  • Software Engineer

Merge overlapping time intervals

Company: Apple

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem: Merge Intervals You are given an array of intervals `intervals`, where each interval is a pair `[start, end]` with `start <= end`. Merge all overlapping intervals and return a new array of non-overlapping intervals that covers all the intervals in the input. ### Overlap definition Two intervals `[a,b]` and `[c,d]` overlap if `c <= b` (assuming `a <= c` after sorting). ### Input / Output - **Input:** `intervals: number[][]` - **Output:** `number[][]` merged intervals ### Example - Input: `[[1,3],[2,6],[8,10],[15,18]]` - Output: `[[1,6],[8,10],[15,18]]` ### Constraints - `1 <= intervals.length <= 10^5` - Interval values fit in 32-bit signed integers. ### Follow-ups - What is the time complexity of your approach? - How do you handle already-sorted vs unsorted inputs?

Quick Answer: This question evaluates competence in interval and array manipulation, sorting-based algorithm design, overlap detection, and efficient time/space complexity reasoning.

Related Interview Questions

  • Compute Earliest Bus Arrival - Apple (medium)
  • Find the Extra Edge - Apple (hard)
  • Rotate a Matrix In Place - Apple (medium)
  • Encode and Rebuild a Binary Tree - Apple (hard)
  • Wrap Matching Substrings in Bold Tags - Apple (medium)
Apple logo
Apple
Feb 12, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
8
0
Loading...

Problem: Merge Intervals

You are given an array of intervals intervals, where each interval is a pair [start, end] with start <= end.

Merge all overlapping intervals and return a new array of non-overlapping intervals that covers all the intervals in the input.

Overlap definition

Two intervals [a,b] and [c,d] overlap if c <= b (assuming a <= c after sorting).

Input / Output

  • Input: intervals: number[][]
  • Output: number[][] merged intervals

Example

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

Constraints

  • 1 <= intervals.length <= 10^5
  • Interval values fit in 32-bit signed integers.

Follow-ups

  • What is the time complexity of your approach?
  • How do you handle already-sorted vs unsorted inputs?

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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