FunctionRacerProblemsRace

Join Overlapping Spans

HardNumPyPython

Each row of spans is [start, end] with start <= end. Join every group of spans that overlap or touch ([1, 2] and [2, 5] touch) into one span, and return the joined spans sorted by start. No loops: for and while are not allowed.

Example 1

spans [[1,3],[8,10],[2,6],[15,18]]
returns [[1,6],[8,10],[15,18]]

[1, 3] and [2, 6] overlap and become [1, 6]. The other two stand alone.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems