Given a list of intervals, merge all overlapping ones. e.g. [[1,3],[2,6],[8,10]] → [[1,6],[8,10]].
The universal interval move: sort by start, then a single sweep.
Sort by start. Walk through; if the current interval starts before the last merged one ends, they overlap — extend the end to the max. Otherwise push a new interval. Almost every interval problem starts with 'sort by start'. The O(n log n) is dominated by the sort; the sweep is O(n). Watch the merge detail — extend with `Math.max(last[1], cur[1])`, not just `cur[1]`, because a fully-nested interval like [1,10] then [2,3] must keep the 10. Sorting by start is the setup move for insert-interval, meeting-rooms (min rooms = max concurrent), and interval-intersection; a few variants instead sort by end (for greedy 'maximum non-overlapping intervals').
Overlapping ranges — merge, insert, count rooms, detect conflicts → sort by start, sweep once.
Time O(n log n) · Space O(n)