const dt = [
[1, 2],
[1, 3],
[2, 4],
[2, 3]
]
let arr = dt.flat();
let min = Math.min(...arr);
let max = Math.max(...arr);
let t = 0;
for (let i = min; i <= max; i++) {
let c = 0;
dt.forEach(el => {
if ((el[0] <= i) && (i < el[1])) ++c
})
alert(i + ' - ' + c)
t = Math.max(t, c)
}
alert(t)
const dt = [
[1, 2],
[1, 3],
[2, 4],
[2, 3]
]
let arr = dt.map(([a, b]) => Array.from({
length: b - a
}, (_, i) => a + i)).flat().sort((a, b) => a - b);
let c = 0,
t = 0,
n;
for (let i of arr) {
if (i === n) c++;
else {
c = 1;
n = i;
}
if (c > t) t = c;
}
alert(t)