T

TechIdea

Ecosystem

← Back to Python Challenges
PythonIntermediate

Merge Overlapping Intervals

This is a classic FAANG interview question testing your ability to sort arrays and handle edge cases in contiguous data.

Problem Statement

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.

Real World Scenario:

In a calendar application, you have multiple meetings scheduled. You want to merge overlapping meetings to find out the blocks of time where a person is busy.

Input / Output

Input: intervals = [[1,3],[2,6],[8,10],[15,18]]

Output: [[1,6],[8,10],[15,18]]

Constraints

  • 1 <= intervals.length <= 10^4
  • intervals[i].length == 2
  • 0 <= starti <= endi <= 10^4

Interactive Playground

Loading...
Console Output
Click "Run Code" to see the output here.

Need a hint?

Growth Newsletter

Get practical AI tools, SEO tips, and growth guides weekly.

Join creators, students, and businesses scaling with TechIdea.