You are given an array of intervals, where each interval is represented as a pair of integers [start, end] with start <= end. The intervals may be unsorted and may overlap.
Task:
Example:
Constraints (you may assume reasonable values if not specified by the interviewer):
Design an algorithm to perform this merge efficiently and discuss its time and space complexity.