You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
722 B
17 lines
722 B
// Interval: [start, end].
|
|
// Merges two overlapping intervals into one.
|
|
function intervalsMerge(a, b) {
|
|
return [Math.min(a[0], b[0]), Math.max(a[1], b[1])];
|
|
}
|
|
|
|
const deepEqual = require('./deepEqual');
|
|
|
|
console.log(deepEqual(intervalsMerge([1, 2], [1, 4]), [1, 4]));
|
|
console.log(deepEqual(intervalsMerge([1, 2], [0, 4]), [0, 4]));
|
|
console.log(deepEqual(intervalsMerge([1, 2], [0, 2]), [0, 2]));
|
|
console.log(deepEqual(intervalsMerge([1, 2], [0, 1.5]), [0, 2]));
|
|
console.log(deepEqual(intervalsMerge([1, 4], [1, 2]), [1, 4]));
|
|
console.log(deepEqual(intervalsMerge([0, 4], [1, 2]), [0, 4]));
|
|
console.log(deepEqual(intervalsMerge([0, 2], [1, 2]), [0, 2]));
|
|
console.log(deepEqual(intervalsMerge([0, 1.5], [1, 2]), [0, 2]));
|