In this post, we are going to solve a problem merge overlapping intervals.
Given a list of time intervals. Each interval has a start and end time. Write a code to merge all overlapping intervals. The given intervals may or may not be sorted.
For example –
Example 1-
Input: [[1,4], [2,5], [6,9]] Output: [[1,5], [6,9]]
Example 2-
Input: [[7,8], [2,3], [5,9]] Output: [[2,3], [5,9]]
Example 3-
Input: [[1,4], [2,6], [3,5]] Output: [[1,6]]