This question evaluates understanding of interval operations, array manipulation, and algorithmic efficiency, along with correct handling of edge cases and large-scale inputs.

You are given a list of closed intervals on the number line, where each interval is represented as a pair of integers [start, end] with start <= end.
Write a function that merges all overlapping intervals and returns a new list of non-overlapping intervals that cover exactly the same ranges as the input.
The output list can be returned in any order, but within each interval the first element must be the start and the second element must be the end.
Example:
[[1,3], [2,6], [8,10], [15,18]]
[[1,6], [8,10], [15,18]]
[1,3]
and
[2,6]
overlap and are merged into
[1,6]
. The other intervals do not overlap with any others.
Another example:
[[1,4], [4,5]]
[[1,5]]
Constraints:
1 <= n <= 10^5
where
n
is the number of intervals
[-10^9, 10^9]