Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
clean & compact [corrected] solution in Clear category for [old] Merge Intervals by vincent.tscherter
var mergeIntervals = intervals => {
let i = 0, a, b, c, d;
while (i < intervals.length - 1)
[[a, b], [c, d]] = intervals.slice(i),
c <= b + 1 && intervals.splice(i--, 2, [a, Math.max(b, d)]),
i++;
return intervals;
}
June 3, 2018