Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Merge Overlapping Time Intervals

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Merge Overlapping Time Intervals. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given an array of intervals intervals, where each interval is a two-element array [start, end] and start <= end, merge all overlapping intervals and return a new array of non-overlapping intervals covering the same ranges. The output may be returned in sorted order by start time.

Constraints

  • 1 <= len(intervals) <= 10^4
  • intervals[i].length == 2
  • 0 <= start <= end <= 10^6
  • Intervals may appear in any order

Function Signature

def merge_intervals(intervals):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output