Join Overlapping Spans
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
1 <= len(spans) <= 600 <= start <= end <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Move the CentersHard
- Next GenerationHard
- Runs of Equal ValuesHard
- Two Closest PointsHard
- Vote of the NearestHard
- Above Average CountBeginner
- Average TemperatureBeginner
- Black and WhiteBeginner