Data Structures & Algorithms using JavaScript Course
Data Structures & Algorithms using JavaScript
/
Advanced

Merge Intervals

Definition

Given an array of intervals, sort them by start time. Then iterate: if the current interval's start time is less than or equal to the previous interval's end time, merge them by updating the end time.

Explain Like I'm New

If you are busy from 1pm to 3pm, and your friend is busy from 2pm to 4pm, your combined busy schedule is simply 1pm to 4pm.

Interactive Coding Challenges

Merge Intervals

Solution Code

Loading...
Console output will appear here...
O(N log N) Time, O(N) Space.