Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the intervals in the input.
[[1,3],[2,6],[8,10],[15,18]][[1,6],[8,10],[15,18]]startcurr[0] > last[1] → no overlap, add curr as newlast[1] = max(last[1], curr[1])After sorting by start, any interval that overlaps with the last merged interval must have curr.start ≤ last.end. Extending last.end captures the full overlap. Non-overlapping intervals start after last.end, so we add them fresh.