EC
Size: a a a
EC
IS
IS
Кm
IS
BB
RR
RR
v
const callList = [не ручаюсь за 100% правильность решения (не проверял эдж кейсы).
{from: 1200, to: 1215},
{from: 1212, to: 1215},
{from: 1232, to: 1255},
{from: 1253, to: 1400},
{from: 1200, to: 1400},
];
const intersections = new Map();
function getIntersections (call) {
return callList.filter(filtered => Math.max(0, Math.min(call.to, filtered.to) - Math.max(call.from, filtered.from) + 1) > 0);
}
function setIntersection (call) {
intersections.set([call.from, call.to], getIntersections(call))
}
callList.forEach(setIntersection);
BB
RR
DK
ЕМ
BB
IS
BB
ЕМ
BS