const solution = (lines) => {
const stage = new Set();
const overlapped = new Set();
lines.forEach(([start, end]) => {
for (let num = start; num < end; num++) {
if (stage.has(num)) {
overlapped.add(num);
}
stage.add(num)
}
})
const answer = overlapped.size;
return answer;
}
Set 자료형 2개를 이용해서 겹치는 선분을 찾아간다