A road is represented as a single continuous line. Every position on the road is identified by an integer marker.
A maintenance team receives several road sections that need repair. Each section includes every position from its starting marker through its ending marker.
Combine all repair sections that overlap or touch each other. Return the resulting separate repair zones.
List<String> combineRepairZones(List<String> repairZones)
repairZones: The sections that need repair."startMarker,endMarker".The combined repair zones, formatted as "startMarker,endMarker".
Return the zones in ascending order of their starting markers.
1 ≤ repairZones.size() ≤ 10,000repairZones is formatted as "startMarker,endMarker". 0 ≤ startMarker ≤ endMarker ≤ 1,000,000 repairZones is never null and never contains null values. combineRepairZones( repairZones = List.of("30,38", "7,12", "10,18", "50,55"))
Returns List.of("7,18", "30,38", "50,55").
The sections "7,12" and "10,18" overlap, so they become the single repair zone "7,18".
combineRepairZones( repairZones = List.of("4,9", "9,14", "20,24"))
Returns List.of("4,14", "20,24").
The first two sections touch at marker 9, so they form one continuous repair zone.
combineRepairZones( repairZones = List.of( "40,45", "6,11", "8,16", "15,22", "21,28", "60,63"))
Returns List.of("6,28", "40,45", "60,63").
The four connected sections from marker 6 through marker 28 are combined into one repair zone.